<@class name="SvgScrollable" inherit="SvgBehavior" hide="yes"> A scrollable element behavior (c) SAP AG 2003-2006. All rights reserved. // constructor function SvgScrollable(peer, props) { this.board = BOARD; this.moving = false; this.attach(peer, props); if (this.target && typeof this.target == 'object') { if (!this.onScrollStart) this.onScrollStart = 'onScrollStart'; if (!this.onScrollMove) this.onScrollMove = 'onScrollMove'; if (!this.onScrollEnd) this.onScrollEnd = 'onScrollEnd'; } } SVG.declareClass(SvgScrollable, SvgBehavior); ////////////////////////////////////////////////////////////////////////////////////// // PROPERTIES <@prop name="target:Object">Target object <@prop name="onScrollStart" type="String|Function">The method/function to invoke when the scroll operation is started <@prop name="onScrollMove" type="String|Function">The method/function to invoke while the scroll operation is going on <@prop name="onScrollEnd" type="String|Function">The method/function to invoke when the scroll operation is ended ////////////////////////////////////////////////////////////////////////////////////// // PRIVATE SvgScrollable.prototype.listeners = ['mousedown']; SvgScrollable.prototype.mousedown = function(evt) { SvgScrollable.current = this; var board=this.board; this.client = {x:evt.clientX, y:evt.clientY}; this.origin = board.clientToScreen(this.client); this.offset = {x:0, y:0}; this.button = evt.button; this.moving = true; var ext=board.extBody; ext.onmousemove = SvgScrollable.mousemove; ext.onmouseup = SvgScrollable.mouseup; ext.onlosecapture = SvgScrollable.mouseup; ext.setCapture(true); this.callTarget(this.onScrollStart); } SvgScrollable.mousemove = function() { if (event.button == 0) { SvgScrollable.mouseup(); return; } var current = SvgScrollable.current; if (!current || !current.moving) return; current.client.x = event.clientX; current.client.y = event.clientY; current.offset.x = event.screenX-current.origin.x; current.offset.y = event.screenY-current.origin.y; current.callTarget(current.onScrollMove); } SvgScrollable.mouseup = function() { var current = SvgScrollable.current; if (!current || !current.moving) return; current.moving = false; var ext=current.board.extBody; ext.releaseCapture(); ext.onmousemove = null; ext.onmouseup = null; current.callTarget(current.onScrollEnd); SvgScrollable.current = null; focus(); }