问题
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