Easeljs Scrollable Container

▼魔方 西西 提交于 2019-12-11 11:18:40

问题


I have an Easeljs container that contains rows of buttons which is taller than the height of the screen. Is it possible to have the container scroll (pan) vertically using touch? Imagine that the container will be the width of the device and approx .80% height. It will be 10% down from the top, and in the bottom 10% will be navigation buttons that should not be scrolled. I guess I could use the DOMElement but the rest of the app has been built using createjs containers only. The app will be pushed out through Cordova to Android and IOS devices. Any ideas please?


回答1:


Here is a super quick sample of a "draggable" canvas, that should give you some ideas. The code is a little old, so it might be slightly out of date with the latest EaselJS version, but the approach is the same.

http://jsfiddle.net/lannymcnie/jKuyy/

Sample Code:

dragBox.addEventListener("mousedown", startDrag); // Object listens to mouse press
function startDrag(event) {
    // Get offset (not shown here, see fiddle)
    event.addEventListener("mousemove", doDrag);
}
function doDrag(event) {
    // Reposition content using event.stageX and event.stageY (the new mouse coordinates)
}

Here is the original SO post: Infinite canvas with EaselJS



来源:https://stackoverflow.com/questions/30177659/easeljs-scrollable-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!