Skip to main content
Participating Frequently
Dec 23, 2021 2:29 PM UTC
Answered

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

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 is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Dec 27, 2021 11:58 AM UTC

    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

    5 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    Dec 27, 2021 11:59 AM UTC

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

    Translate
    Participating Frequently
    Dec 28, 2021 1:19 PM UTC

    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?

    Translate
    JoãoCésar17023019
    Community Expert
    Community Expert
    Dec 28, 2021 4:26 PM UTC

    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

    Translate
    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Dec 27, 2021 11:58 AM UTC

    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

    Translate