At first glance, this drawing code might be the problem:
Code:
reaper.JS_Composite(track_window,
math.ceil(item_start * zoom_lvl) - Arr_pixel, -- X
item_t - y_view_start + item_bar, -- Y
math.ceil(item_lenght * zoom_lvl), -- W
item_h, -- H
item_bm,
0, --x
0, --y
math.ceil((item_lenght * zoom_lvl)), --w
item_h) --h
end
The last --w and --h lines probably cut off part of the bitmap. To shrink and expand the ghost, the entire source bitmap must be composited, so (source w and h remain constant), and only the image size W and H in the track window changes.