touch/mouse events are both handled simultaneously, module rewritten for better performances (see issue #18)
This commit is contained in:
parent
598cbd1099
commit
892eaae7ff
14 changed files with 610 additions and 496 deletions
|
|
@ -179,11 +179,11 @@ module.exports = {
|
|||
|
||||
traversingDisable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
TRAVERSING = false
|
||||
$(document).trigger('disableTraversingGestures')
|
||||
},
|
||||
traversingEnable: function(){
|
||||
$('.traversingEnable, .traversingDisable').toggleClass('on')
|
||||
TRAVERSING = true
|
||||
$(document).enableTraversingGestures()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ var correctPosition = function (m, parent){
|
|||
}
|
||||
}
|
||||
|
||||
var ev = 'touchstart mousedown'
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var menu = function(e,actions,parent){
|
||||
|
|
@ -37,9 +37,6 @@ var menu = function(e,actions,parent){
|
|||
$(`<div class="item">${label}</div>`).on(ev + '.editor',function(){
|
||||
var callback = actions[label]
|
||||
return function(e){
|
||||
// ignore mouse event when fired by a simulated touch event
|
||||
if (e.originalEvent.sourceCapabilities.firesTouchEvents) return
|
||||
|
||||
callback()
|
||||
$('.context-menu').remove()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
|
||||
var ev = 'touchstart mousedown'
|
||||
var ev = 'fake-click'
|
||||
|
||||
|
||||
var editObject = function(container, data, refresh){
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ var data = require('./data-workers'),
|
|||
|
||||
var init = function(){
|
||||
|
||||
var ev = 'touchstart mousedown'
|
||||
|
||||
$('body').off('.editor').on(ev+'.editor fake-right-click',function(e,d){
|
||||
$('body').off('.editor').on('fake-click fake-right-click',function(e,d){
|
||||
|
||||
if (!EDITING) return
|
||||
|
||||
|
|
|
|||
|
|
@ -180,8 +180,9 @@ module.exports.create = function(widgetData,container) {
|
|||
})
|
||||
|
||||
var off = 0
|
||||
wrapper.on('draginit',function(e,data){
|
||||
if (snap || TRAVERSING) {
|
||||
wrapper.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var d = (dimension=='height')?
|
||||
((fader.size-data.offsetY+(wrapper.size-fader.size)/2) * 100 / fader.size):
|
||||
(data.offsetX - (wrapper.size-fader.size)/2) * 100 / fader.size
|
||||
|
|
@ -208,11 +209,7 @@ module.exports.create = function(widgetData,container) {
|
|||
})
|
||||
|
||||
|
||||
wrapper.on('drag',function(e,data,originalEvent){
|
||||
|
||||
if (originalEvent) originalEvent.preventDefault()
|
||||
|
||||
if (TRAVERSING) return
|
||||
wrapper.on('drag',function(e,data){
|
||||
|
||||
var d = (dimension=='height')?-data.deltaY:data.deltaX
|
||||
d = clip(d*100/fader.size+off,[0,100])
|
||||
|
|
|
|||
|
|
@ -140,9 +140,10 @@ module.exports.create = function(widgetData,container) {
|
|||
var offR = 0,
|
||||
offX = 0,
|
||||
offY = 0
|
||||
wrapper.on('draginit',function(e,data){
|
||||
wrapper.on('draginit',function(e,data,traversing){
|
||||
|
||||
if (snap || traversing) {
|
||||
|
||||
if (snap || TRAVERSING) {
|
||||
var w = wrapper.size.width,
|
||||
h = wrapper.size.height,
|
||||
x = data.offsetX-w/2,
|
||||
|
|
@ -175,11 +176,7 @@ module.exports.create = function(widgetData,container) {
|
|||
offR = knob.rotation
|
||||
})
|
||||
|
||||
wrapper.on('drag',function(e,data,originalEvent){
|
||||
|
||||
if (originalEvent) originalEvent.preventDefault()
|
||||
|
||||
if (TRAVERSING) return
|
||||
wrapper.on('drag',function(e,data){
|
||||
|
||||
var r = clip(-data.deltaY*2+offR,[0,270])
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ module.exports.create = function(widgetData,container) {
|
|||
return widget.value
|
||||
}
|
||||
|
||||
widget.handleDragging(true)
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ module.exports.create = function(widgetData,container) {
|
|||
return widget.value
|
||||
}
|
||||
|
||||
widget.handleDragging(true)
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ module.exports.create = function(widgetData,container) {
|
|||
return widget.value
|
||||
}
|
||||
|
||||
widget.handleDragging(true)
|
||||
widget.enableTraversingGestures()
|
||||
|
||||
return widget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,9 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
|
||||
var rgbOff = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data){
|
||||
if (snap || TRAVERSING) {
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
|
|
@ -105,11 +106,7 @@ module.exports.create = function(widgetData,container) {
|
|||
rgbOff = {x:rgbHandle.width,y:rgbHandle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data,originalEvent){
|
||||
|
||||
if (originalEvent) originalEvent.preventDefault()
|
||||
|
||||
if (TRAVERSING) return
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
|
||||
w = clip(data.deltaX*100/pad.width+rgbOff.x,[0,100])
|
||||
|
|
@ -133,8 +130,9 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
|
||||
var hueOff = 0
|
||||
huePad.on('draginit',function(e,data){
|
||||
if (snap || data.ctrlKey || data.shiftKey) {
|
||||
huePad.on('draginit',function(e,data,traversing){
|
||||
if (snap || traversing) {
|
||||
|
||||
var d = (data.offsetX * 100 / pad.width)
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*d/100}px,0,0)`)
|
||||
hueHandle.width = d
|
||||
|
|
@ -163,11 +161,7 @@ module.exports.create = function(widgetData,container) {
|
|||
})
|
||||
|
||||
|
||||
huePad.on('drag',function(e,data,originalEvent){
|
||||
|
||||
if (originalEvent) originalEvent.preventDefault()
|
||||
|
||||
if (TRAVERSING) return
|
||||
huePad.on('drag',function(e,data){
|
||||
|
||||
var w = clip(data.deltaX*100/pad.width+hueOff,[0,100])
|
||||
hueHandle[0].setAttribute('style',`transform:translate3d(${pad.width*w/100}px,0,0)`)
|
||||
|
|
|
|||
|
|
@ -79,8 +79,9 @@ module.exports.create = function(widgetData,container) {
|
|||
})
|
||||
|
||||
var off = {x:0,y:0}
|
||||
pad.on('draginit',function(e,data){
|
||||
if (snap || TRAVERSING) {
|
||||
pad.on('draginit',function(e,data,traversing){
|
||||
|
||||
if (snap || traversing) {
|
||||
var h = ((pad.height-data.offsetY) * 100 / pad.height),
|
||||
w = (data.offsetX * 100 / pad.width)
|
||||
|
||||
|
|
@ -105,11 +106,7 @@ module.exports.create = function(widgetData,container) {
|
|||
off = {x:handle.width,y:handle.height}
|
||||
|
||||
})
|
||||
pad.on('drag',function(e,data,originalEvent){
|
||||
|
||||
if (originalEvent) originalEvent.preventDefault()
|
||||
|
||||
if (TRAVERSING) return
|
||||
pad.on('drag',function(e,data){
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
|
||||
w = clip((data.deltaX)*100/pad.width+off.x,[0,100])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue