Merge branch 'pr/same-widget-traversing' of https://github.com/MartinHN/open-stage-control into MartinHN-pr/same-widget-traversing
This commit is contained in:
commit
f1d2dc0512
2 changed files with 51 additions and 10 deletions
|
|
@ -2,7 +2,9 @@ const {normalizeDragEvent, resetEventOffset} = require('./utils')
|
|||
const iOS = require('../ui/ios')
|
||||
|
||||
var targets = {},
|
||||
previousPointers = {}
|
||||
previousPointers = {},
|
||||
startDraggedClass ='',
|
||||
sameWidgetPolicy = false
|
||||
|
||||
function pointerDownHandler(event) {
|
||||
|
||||
|
|
@ -36,9 +38,23 @@ function pointerMoveHandler(event) {
|
|||
target = event.isTouch ?
|
||||
document.elementFromPoint(event.clientX, event.clientY)
|
||||
: event.target
|
||||
,updateTarget=true
|
||||
|
||||
if (target) target = target.closest('.drag-event')
|
||||
|
||||
if(sameWidgetPolicy && target ){
|
||||
console.log(startDraggedClass)
|
||||
if(!startDraggedClass){
|
||||
startDraggedClass = target._drag_widget.getProp('type')
|
||||
}
|
||||
else{
|
||||
if(target._drag_widget.getProp('type')!= startDraggedClass){
|
||||
target = null
|
||||
updateTarget = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (target && event.isTouch) {
|
||||
resetEventOffset(event, target)
|
||||
}
|
||||
|
|
@ -50,11 +66,14 @@ function pointerMoveHandler(event) {
|
|||
|
||||
if (target) {
|
||||
if (event.traversingContainer.contains(target)) {
|
||||
triggerWidgetEvent(target, previousTarget !== target ? 'draginit' : 'drag', event)
|
||||
var init = previousTarget !== target
|
||||
// console.log(startDraggedClass,previousTarget?previousTarget._drag_widget:'null',target?target._drag_widget:'null',init)
|
||||
triggerWidgetEvent(target, init? 'draginit' : 'drag', event)
|
||||
}
|
||||
}
|
||||
|
||||
targets[event.pointerId] = target
|
||||
if(updateTarget)
|
||||
targets[event.pointerId] = target
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
|
@ -73,7 +92,7 @@ function pointerUpHandler(event) {
|
|||
|
||||
delete targets[event.pointerId]
|
||||
delete previousPointers[event.pointerId]
|
||||
|
||||
startDraggedClass = ''
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -253,7 +272,8 @@ module.exports = {
|
|||
|
||||
},
|
||||
|
||||
enableTraversingGestures: function(element) {
|
||||
enableTraversingGestures: function(element,options) {
|
||||
sameWidgetPolicy = options?options.sameWidgetPolicy:false
|
||||
|
||||
function makeEventTraversing(event) {
|
||||
if (event.ctrlKey) return
|
||||
|
|
|
|||
|
|
@ -54,18 +54,39 @@ var sidepanelData = [
|
|||
{
|
||||
title: locales('traversing_on'),
|
||||
action:()=>{
|
||||
DOM.each(document, '.traversingEnable, .traversingDisable', (el)=>{
|
||||
el.classList.toggle('on')
|
||||
DOM.each(document, '.traversingDisable, .traversingSame', (el)=>{
|
||||
el.classList.remove('on')
|
||||
})
|
||||
DOM.each(document, '.traversingEnable', (el)=>{
|
||||
el.classList.add('on')
|
||||
})
|
||||
// disableTraversingGestures(document.getElementById('container'))
|
||||
enableTraversingGestures(document.getElementById('container'))
|
||||
},
|
||||
class:'traversingEnable'
|
||||
},
|
||||
{
|
||||
title: locales('traversing_off'),
|
||||
title: locales('traversing_same'),
|
||||
action:()=>{
|
||||
DOM.each(document, '.traversingEnable, .traversingDisable', (el)=>{
|
||||
el.classList.toggle('on')
|
||||
el.classList.remove('on')
|
||||
})
|
||||
DOM.each(document, '.traversingSame', (el)=>{
|
||||
el.classList.add('on')
|
||||
})
|
||||
// disableTraversingGestures(document.getElementById('container'))
|
||||
enableTraversingGestures(document.getElementById('container'),{sameWidgetPolicy:true})
|
||||
},
|
||||
class:'traversingSame'
|
||||
},
|
||||
{
|
||||
title: locales('traversing_off'),
|
||||
action:()=>{
|
||||
DOM.each(document, '.traversingEnable, .traversingSame', (el)=>{
|
||||
el.classList.remove('on')
|
||||
})
|
||||
DOM.each(document, '.traversingDisable', (el)=>{
|
||||
el.classList.add('on')
|
||||
})
|
||||
disableTraversingGestures(document.getElementById('container'))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue