scroll - How do I lock a carousel in Sencha Touch -
i using carousel , lock carousel until button clicked. there easy way this? thanks!
my code far:
ext.define('babyben.view.maincarousel', { extend: 'ext.carousel.carousel', xtype: 'maincarousel', config: { fullscreen: true, activeitem: 1, indicator: false, scrollable: { direction: 'vertical', directionlock: true }, items: [{ xtype: 'whatscreen' }, { xtype: 'startscreen' }, { xtype: 'whenscreen' }] } });
you need write custom view lockable carousel:
ext.define("myapp.view.lockablecarousel",{ extend: 'ext.carousel', initialize: function () { this.ondragorig = this.ondrag; this.ondrag = function (e) { if(!this.locked){this.ondragorig(e);} } }, locked: false, lock: function () { this.locked = true; }, unlock: function () { this.locked = false; } });
then can extend custom carousel anywhere using extend
need apply custom lock
, unlock
function desired lockable carousel through button handler:
ext.define("myapp.view.customcarousel",{ xtype: 'customcarousel', extend: 'myapp.view.lockablecarousel', config: { id: 'lockablecarousel', title: 'example4', iconcls: 'cloud', indicator: false, items: [ { html : 'item 1', style: 'background-color: #5e99cc' }, { items: [ { xtype : 'button', text: 'lock', handler:function() { ext.getcmp('lockablecarousel').lock(); } }, { xtype : 'button', text: 'unlock', handler:function() { ext.getcmp('lockablecarousel').unlock(); } } ] } ] } });
Comments
Post a Comment