Mouse snap when using pressmove
I am re-creating a timeline scrubber from Edge which is just about working, but I am having trouble getting my slider button (sliderBtn) to snap to the mouse when I drag it. I have it set to drag within the boundaries of a rectangle (like a video timeline scrubber), but when I press and drag the sliderBtn seems to jump about 50 pixels to the right of where my mouse pointer is. Any thoughts? Note that I am setting the tick event to paused when you roll over the rectangle so that the animation stops when you're scrubbing.
scrubBoundary = new createjs.Shape();
scrubBoundary.graphics.beginStroke("#999")
.setStrokeStyle(1)
.beginFill("red")
.drawRect(247, 527, 455, 10);
scrubBoundary.snapToPixel = true;
scrubBoundary.setBounds(247, 527, 455, 10);
bounds = scrubBoundary.getBounds();
stage.addChild(scrubBoundary);
//Create slider button
sliderBtn = new lib.sliderBtn();
sliderBtn.cursor = "pointer";
stage.addChild(sliderBtn);
function handleTick(event) {
if(!event.paused && exportRoot.currentFrame < exportRoot.totalFrames){
sliderBtn.x = bounds.x + bounds.width * (exportRoot.currentFrame / exportRoot.totalFrames);
}
}
scrubBoundary.on("mouseover", function (evt) {
paused = false;
doPauseActions();
});
sliderBtn.on("pressmove", function (evt) {
evt.currentTarget.x = Math.max(bounds.x, Math.min(bounds.x + bounds.width - sliderBtn.getBounds().width, evt.stageX));
controlTimeline();
});
