css: gutter system, again (consistent spacing between widgets)
js: [touch] master dragging behaviour fixed, now the actual element under the finger is retrieved by the event handler
This commit is contained in:
parent
7e7302a529
commit
3db95aa9c9
5 changed files with 63 additions and 38 deletions
|
|
@ -67,7 +67,6 @@ init = function(session,callback) {
|
|||
|
||||
if ($('#sidepanel').has(dd.target)[0]) return
|
||||
dd.absolute=true
|
||||
dd.shiftKey=false
|
||||
$(dd.target).trigger('draginit',[dd])
|
||||
if (target!=dd.target) $(dd.target).click()
|
||||
target = dd.target
|
||||
|
|
|
|||
|
|
@ -111,6 +111,8 @@ createWidget.strip = function(widgetData,container) {
|
|||
`)
|
||||
if (widgetData.horizontal) {
|
||||
container.addClass('horizontal')
|
||||
} else {
|
||||
container.addClass('vertical')
|
||||
}
|
||||
parsewidgets(widgetData.widgets,widget)
|
||||
widget.getValue = function(){return}
|
||||
|
|
@ -224,19 +226,28 @@ createWidget.push = function(widgetData) {
|
|||
<div class="push toggle">
|
||||
<div class="light"></div>
|
||||
</div>\
|
||||
`)
|
||||
`),
|
||||
$document = $(document)
|
||||
|
||||
widget.value = widget.find('span')
|
||||
|
||||
widget.on('drag',function(){})
|
||||
widget.on('drag',function(e){e.stopPropagation()})
|
||||
widget.on('draginit',function(){
|
||||
widget.setValue(widgetData.on,true)
|
||||
widget.on('dragend',function(){
|
||||
widget.setValue(widgetData.off,true)
|
||||
widget.off('dragend')
|
||||
})
|
||||
widget.off('draginit')
|
||||
widget.fakeclick()
|
||||
})
|
||||
|
||||
widget.fakeclick = function(){
|
||||
widget.setValue(widgetData.on,true)
|
||||
$document.on('dragend.push',function(){
|
||||
widget.setValue(widgetData.off,true)
|
||||
$document.off('dragend.push')
|
||||
widget.on('draginit.push',function(){
|
||||
widget.off('draginit.push')
|
||||
widget.fakeclick()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
widget.getValue = function() {
|
||||
return widget.hasClass('on')?widgetData.on:widgetData.off
|
||||
|
|
@ -372,6 +383,8 @@ createWidget.xy = function(widgetData) {
|
|||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+off.y,[0,100]),
|
||||
|
|
@ -516,6 +529,8 @@ createWidget.rgb = function(widgetData) {
|
|||
|
||||
})
|
||||
pad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
var h = clip((-data.deltaY)*100/pad.height+rgbOff.y,[0,100]),
|
||||
|
|
@ -561,6 +576,7 @@ createWidget.rgb = function(widgetData) {
|
|||
|
||||
|
||||
huePad.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
|
|
@ -703,7 +719,6 @@ createWidget.fader = function(widgetData,container){
|
|||
dimension = widgetData.horizontal?'width':'height',
|
||||
absolute = widgetData.absolute
|
||||
|
||||
if (widgetData.gauge===false) fader.addClass('nogauge')
|
||||
if (widgetData.horizontal) container.addClass('horizontal')
|
||||
|
||||
handle.size = 0
|
||||
|
|
@ -740,6 +755,7 @@ createWidget.fader = function(widgetData,container){
|
|||
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
|
|
@ -919,6 +935,7 @@ createWidget.knob = function(widgetData) {
|
|||
})
|
||||
|
||||
wrapper.on('drag',function(e,data){
|
||||
e.stopPropagation()
|
||||
|
||||
if (data.shiftKey) return
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
element.on("touchstart.drag mousedown.drag", function(e) {
|
||||
e.preventDefault()
|
||||
previousEvent = e
|
||||
|
||||
if (!e.originalEvent.changedTouches) {
|
||||
// mouse
|
||||
|
|
@ -78,19 +79,21 @@
|
|||
e.deltaY = 0
|
||||
|
||||
element.trigger("draginit", e)
|
||||
previousEvent = e
|
||||
})
|
||||
element.on("touchmove.drag", function(e) {
|
||||
e.preventDefault()
|
||||
|
||||
// get element under pointer: usefull only for master dragging (when target changes during drag)
|
||||
e.target = document.elementFromPoint(e.originalEvent.changedTouches[0].clientX, e.originalEvent.changedTouches[0].clientY)
|
||||
|
||||
e.pageX = e.originalEvent.changedTouches[0].pageX
|
||||
e.pageY = e.originalEvent.changedTouches[0].pageY
|
||||
e.offsetX = e.pageX-getOffset(e.target).left
|
||||
e.offsetY = e.pageY-getOffset(e.target).top
|
||||
e.speedX = e.pageX - previousEvent.pageX
|
||||
e.speedY = e.pageY - previousEvent.pageY
|
||||
e.deltaX = e.speedX + previousEvent.deltaX
|
||||
e.deltaY = e.speedY + previousEvent.deltaY
|
||||
e.speedX = previousEvent?e.pageX - previousEvent.pageX:0
|
||||
e.speedY = previousEvent?e.pageY - previousEvent.pageY:0
|
||||
e.deltaX = previousEvent?e.speedX + previousEvent.deltaX:0
|
||||
e.deltaY = previousEvent?e.speedY + previousEvent.deltaY:0
|
||||
|
||||
// do now allow two touch points to drag the same element
|
||||
if (e.originalEvent.targetTouches.length > 1) return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue