experimenting with ui-control, still a stub...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-09 04:45:04 +03:00
parent 15e8cad1c3
commit 77f830d5ee

View File

@ -1546,6 +1546,7 @@ module.AutoHideCursor = core.ImageGridFeatures.Feature({
/*********************************************************************/ /*********************************************************************/
// Touch/Control... // Touch/Control...
/*
// XXX add zoom... // XXX add zoom...
// XXX add vertical pan to ribbon-set... // XXX add vertical pan to ribbon-set...
var DirectControlHammer = var DirectControlHammer =
@ -1644,12 +1645,10 @@ module.DirectControlHammer = core.ImageGridFeatures.Feature({
that.updateRibbon(central) that.updateRibbon(central)
// XXX add inertia.... // XXX add inertia....
/* XXX //console.log('!!!!', g.velocityX)
console.log('!!!!', g.velocityX) //r.velocity({
r.velocity({ // translateX: (data.left + g.deltaX + (g.velocityX * 10)) +'px'
translateX: (data.left + g.deltaX + (g.velocityX * 10)) +'px' //}, 'easeInSine')
}, 'easeInSine')
*/
// silently focus central image... // silently focus central image...
if(that.config['focus-central-image'] == 'silent'){ if(that.config['focus-central-image'] == 'silent'){
@ -1751,12 +1750,13 @@ module.IndirectControl = core.ImageGridFeatures.Feature({
function(){ a.toggleSwipeHandling('off') }], function(){ a.toggleSwipeHandling('off') }],
], ],
}) })
*/
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// XXX still a stub.... // XXX STUB: needs more thought....
var ControlActions = actions.Actions({ var ControlActions = actions.Actions({
config: { config: {
'control-mode': 'indirect', 'control-mode': 'indirect',
@ -1769,7 +1769,7 @@ var ControlActions = actions.Actions({
}, },
// XXX not working correctly after cycling on -> off -> on... // XXX .off(..) appears not to be working with hammer events...
toggleRibbonPanHandling: ['Interface/Toggle ribbon pan handling', toggleRibbonPanHandling: ['Interface/Toggle ribbon pan handling',
toggler.Toggler(null, toggler.Toggler(null,
function(){ function(){
@ -1847,7 +1847,11 @@ var ControlActions = actions.Actions({
// silently focus central image... // silently focus central image...
if(that.config['focus-central-image'] == 'silent'){ if(that.config['focus-central-image'] == 'silent'){
that.data.current = that.ribbons.getElemGID(central) var gid = that.ribbons.getElemGID(central)
// XXX is this the right way to do this???
that.data.focusImage(gid)
that.ribbons.focusImage(gid)
// focus central image in a normal manner... // focus central image in a normal manner...
} else if(that.config['focus-central-image']){ } else if(that.config['focus-central-image']){
@ -1872,14 +1876,18 @@ var ControlActions = actions.Actions({
// off... // off...
} else { } else {
this.off('updateRibbon', handler) this.off('updateRibbon', handler)
this.data.ribbon_order.forEach(function(gid){ this.data.ribbon_order.forEach(function(gid){
that.ribbons.getRibbon(gid) that.ribbons.getRibbon(gid)
.removeClass('draggable') //.removeClass('draggable')
.off('pan') // XXX this does not remove the hammer trigger
// ...just the jQuery handler is cleared
//.off('pan')
.removeData('hammer') .removeData('hammer')
}) })
} }
})], })],
// XXX .off(..) appears not to be working with hammer events...
toggleSwipeHandling: ['Interface/Toggle swipe handling', toggleSwipeHandling: ['Interface/Toggle swipe handling',
toggler.Toggler(null, toggler.Toggler(null,
function(_, state){ function(_, state){
@ -1903,24 +1911,33 @@ var ControlActions = actions.Actions({
var h = viewer.data('hammer') var h = viewer.data('hammer')
h.get('swipe').set({direction: Hammer.DIRECTION_ALL}) h.get('swipe').set({direction: Hammer.DIRECTION_ALL})
viewer if(!viewer.hasClass('swipable')){
.on('swipeleft', function(){ that.__panning || that.nextImage() }) viewer
.on('swiperight', function(){ that.__panning || that.prevImage() }) .addClass('swipable')
.on('swipeup', function(){ that.__panning || that.shiftImageUp() }) .on('swipeleft', function(){
.on('swipedown', function(){ that.__panning || that.shiftImageDown() }) that.__panning || that.nextImage() })
.on('swiperight', function(){
that.__panning || that.prevImage() })
.on('swipeup', function(){
that.__panning || that.shiftImageUp() })
.on('swipedown', function(){
that.__panning || that.shiftImageDown() })
}
// off... // off...
} else { } else {
this.ribbons.viewer this.ribbons.viewer
.off('swipeleft') // XXX
.off('swiperight') //.off('swipeleft')
.off('swipeup') //.off('swiperight')
.off('swipedown') //.off('swipeup')
//.off('swipedown')
.removeData('hammer') .removeData('hammer')
} }
})], })],
// XXX we are not using this....
__control_mode_handlers__: { __control_mode_handlers__: {
indirect: indirect:
function(state){ function(state){
@ -1930,7 +1947,6 @@ var ControlActions = actions.Actions({
function(state){ function(state){
}, },
}, },
toggleControlMode: ['- Interface/', toggleControlMode: ['- Interface/',
toggler.Toggler(null, toggler.Toggler(null,
function(){ return this.config['control-mode'] }, function(){ return this.config['control-mode'] },
@ -1985,7 +2001,8 @@ module.Control = core.ImageGridFeatures.Feature({
}], }],
['toggleSingleImage', ['toggleSingleImage',
function(){ function(){
this.toggleRibbonPanHandling(this.toggleSingleImage('?') == 'off' ? 'on' : 'off') this.toggleRibbonPanHandling(
this.toggleSingleImage('?') == 'off' ? 'on' : 'off')
}], }],
], ],
}) })