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
File diff suppressed because one or more lines are too long
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -608,9 +608,11 @@ a {
|
|||
display:none;
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
padding:$gutter;
|
||||
padding-right:0;
|
||||
padding-bottom: 0;
|
||||
padding-top:$gutter;
|
||||
padding-left:$gutter;
|
||||
> .widget {
|
||||
margin-right:$gutter;
|
||||
}
|
||||
&.on {
|
||||
display: block;
|
||||
height:100%;
|
||||
|
|
@ -623,9 +625,8 @@ a {
|
|||
// WIDGETS
|
||||
|
||||
.widget {
|
||||
display:inline-block;
|
||||
border-right:$gutter solid transparent;
|
||||
border-bottom:$gutter solid transparent;
|
||||
display:inline-block;
|
||||
height:auto;
|
||||
min-width: 100rem;
|
||||
overflow: hidden;
|
||||
|
|
@ -649,7 +650,7 @@ a {
|
|||
z-index: 1;
|
||||
padding:10rem 10rem;
|
||||
position:absolute;
|
||||
top:0rem;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
text-overflow:ellipsis;
|
||||
|
|
@ -676,15 +677,6 @@ a {
|
|||
}
|
||||
}
|
||||
|
||||
.master-dragging:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
z-index: 999999;
|
||||
}
|
||||
|
||||
|
||||
/* STRIP (contains any widgets) */
|
||||
|
|
@ -692,7 +684,7 @@ a {
|
|||
|
||||
|
||||
.strip-container {
|
||||
padding-top: 35rem+$gutter;
|
||||
padding-top: 35rem;
|
||||
width:100rem;
|
||||
height:100%;
|
||||
overflow: visible;
|
||||
|
|
@ -715,22 +707,34 @@ a {
|
|||
width:auto;
|
||||
}
|
||||
}
|
||||
&.vertical {
|
||||
padding-top: 35rem + $gutter;
|
||||
.strip {
|
||||
> .widget {
|
||||
border-bottom:$gutter solid transparent;
|
||||
&.last-child {
|
||||
border-bottom:0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
&.horizontal {
|
||||
padding-top:0;
|
||||
padding-left: 35rem+$gutter;
|
||||
padding-left: 35rem + $gutter;
|
||||
width:100%;
|
||||
height:auto;
|
||||
display: block;
|
||||
&.nolabel {
|
||||
padding-left: 0;
|
||||
}
|
||||
.strip {
|
||||
flex-direction: row;
|
||||
|
||||
> .widget {
|
||||
flex-shrink: initial;
|
||||
width:100%;
|
||||
width: 100%;
|
||||
border-bottom:0;
|
||||
border-right:$gutter solid transparent;
|
||||
&.last-child {
|
||||
border-right:0
|
||||
}
|
||||
}
|
||||
}
|
||||
> .label {
|
||||
|
|
@ -749,6 +753,7 @@ a {
|
|||
height:100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -839,6 +844,7 @@ a {
|
|||
.push {
|
||||
&.on .light {
|
||||
animation:none;
|
||||
background: $color-accent;
|
||||
}
|
||||
&:active .light {
|
||||
background: $color-accent;
|
||||
|
|
@ -867,7 +873,7 @@ a {
|
|||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
&:after {
|
||||
&:before {
|
||||
left:50%;
|
||||
top:8rem;
|
||||
width:8rem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue