在http://www.associationtsunami.org/网站上,如果我在文档上按下鼠标,立方体会根据用户移动鼠标的方向旋转。
代码是:
key code ...
).bind('mousedown touchstart', function (evt) {
delete mouse.last;
if ($(evt.target).is('a, iframe')) {
return true;
}
evt.originalEvent.touches ? evt = evt.originalEvent.touches[0] : null;
mouse.start.x = evt.pageX;
mouse.start.y = evt.pageY;
$(document).bind('mousemove touchmove', function (event) {
dragging = 1;
// Only perform rotation if one touch or mouse (e.g. still scale with pinch and zoom)
if (!touch || !(event.originalEvent && event.originalEvent.touches.length > 1)) {
event.preventDefault();
// Get touch co-ords
event.originalEvent.touches ? event = event.originalEvent.touches[0] : null;
$('.viewport').trigger('move-viewport', { x: event.pageX, y: event.pageY });
}
});
$(document).bind('mouseup touchend', function () {
dragging = 0;
$(document).unbind('mousemove touchmove');
});
});
完整代码https://github.com/AssociationTsunami/tsunami/blob/gh-pages/js/cube.js#L72
如果用户在滚动条上按下鼠标,我想禁用此事件 - 例如,在“ONSONPARLA”页面上有一个带有 ACCORDIONS 的选项卡,如果您打开任何手风琴内容,您会在边缘或内部获得滚动条手风琴,如果您尝试移动滚动条,这也会移动立方体。
在 cube.js 中覆盖它的正确方法是什么,以便在事件位于滚动条元素上时立方体不会转动?