Skip to main content
Participating Frequently
December 23, 2021
Answered

The Event pressmove doesn't work on desktop browsers (windows touchscreen)

  • December 23, 2021
  • 2 replies
  • 787 views

I have this code  that  uses the events mousedown , pressmove and pressup ,it runs fine on Android ,IOS ,and windows . but on windows using the touchscreen I receive mousedown and pressup but the event pressmove not triged.

 

container.addEventListener("pressup", onpressup);
container.addEventListener("pressmove", onpressmove);
container.addEventListener("mousedown", onmousedown);

 

I dont change the target after the mousedown event

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    My best guess is that you'll have to rely on JavaScript's native touch events rather than CreateJS's events for this specific situation.

     

    https://www.w3schools.com/jsref/obj_touchevent.asp

     

    CreateJS is no longer updated, so I don't know if this suit of libraries will ever get any updates for that. Maybe you could try contacting Grant Skinner or someone else on the team.

     

    Regards,

    JC

    2 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 27, 2021

    Alternatively, you can replace pressmove by a tick event and use boolean flags to detect if an instance is being dragged, for example.

    Participating Frequently
    December 28, 2021

    Thank you very much for your clarification. I am using animate to create an interactive application, is there a solution for the container object to receive a native event or do I need to change the libraries?

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 28, 2021

    Hi.

     

    Maybe you won't need native events if you replace the pressmove event by a tick event. Like this:

     

    var container = this.yourContainer;
    var getMouse = function(){ return container.globalToLocal(stage.mouseX, stage.mouseY); };
    var target = null;
    
    createjs.Touch.enable(stage);
    stage.mouseMoveOutside = true;
    container.children.forEach(function(child){ child.mouseChildren = false; });
    
    container.on("mousedown", function(e)
    {
    	var point = getMouse();
    	
    	e.target.offset = { x: point.x - e.target.x, y: point.y - e.target.y };
    	target = e.target;
    });
    
    createjs.Ticker.on("tick", function(e)
    {	
    	if (target)
    	{
    		var point = getMouse();
    		
    		target.x = point.x - target.offset.x;
    		target.y = point.y - target.offset.y;
    	}
    });
    
    container.on("pressup", function(e)
    {
    	target = null;
    });

     

     

    I hope this helps.

     

    Regards,

    JC

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    December 27, 2021

    Hi.

     

    My best guess is that you'll have to rely on JavaScript's native touch events rather than CreateJS's events for this specific situation.

     

    https://www.w3schools.com/jsref/obj_touchevent.asp

     

    CreateJS is no longer updated, so I don't know if this suit of libraries will ever get any updates for that. Maybe you could try contacting Grant Skinner or someone else on the team.

     

    Regards,

    JC