チェンジセット 823
- コミット日時:
- 2008/07/10 19:37:01 (4 年前)
- ファイル:
-
- as3/GeniusFramework/trunk/app-template/libs/Genius.swc (更新) (変更前)
- as3/GeniusFramework/trunk/html-template (削除)
- as3/GeniusFramework/trunk/samples/HelloGenius (更新) (1 prop)
- as3/GeniusFramework/trunk/samples/HelloGenius/html-template (削除)
- as3/GeniusFramework/trunk/samples/HelloGenius/libs/Genius.swc (更新) (変更前)
- as3/GeniusFramework/trunk/samples/Portfolio/flex (更新) (1 prop)
- as3/GeniusFramework/trunk/samples/Portfolio/flex/html-template (削除)
- as3/GeniusFramework/trunk/samples/Portfolio/flex/libs/Genius.swc (更新) (変更前)
- as3/GeniusFramework/trunk/src/jp/seagirl/ui/MouseWheelSupport.as (更新) (6 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/GeniusFramework/trunk/samples/HelloGenius
- 属性の設定値: svn:ignore (変更前)
.project
.flexProperties
bin-debug
bin-release
.actionScriptProperties
.settings
(変更後)
.project
.flexProperties
bin-debug
bin-release
html-template
.actionScriptProperties
.settings
- 属性の設定値: svn:ignore (変更前)
as3/GeniusFramework/trunk/samples/Portfolio/flex
- 属性の設定値: svn:ignore (変更前)
.project
.flexProperties
bin-debug
bin-release
.actionScriptProperties
.settings
(変更後)
.project
.flexProperties
bin-debug
bin-release
html-template
.actionScriptProperties
.settings
- 属性の設定値: svn:ignore (変更前)
as3/GeniusFramework/trunk/src/jp/seagirl/ui/MouseWheelSupport.as
r318 r823 33 33 import flash.geom.Point; 34 34 import flash.system.Capabilities; 35 import flash.utils.getTimer;36 35 37 36 import mx.containers.Canvas; … … 42 41 /** 43 42 * Macでもホイールスクロールが動作するようにするためのクラスです。 44 * MouseWheelSupport.jsを使います。45 43 * 46 44 * @author yoshizu … … 50 48 //-------------------------------------------------------------------------- 51 49 // 50 // Class variables 51 // 52 //-------------------------------------------------------------------------- 53 54 public static const js:String = "" + 55 "function (objectID)" + 56 "{" + 57 " function MouseWheelSupport(swf)" + 58 " {" + 59 " this.swf = swf;" + 60 " this.init();" + 61 " }" + 62 "" + 63 " MouseWheelSupport.prototype =" + 64 " {" + 65 " init: function ()" + 66 " {" + 67 " MouseWheelSupport.instance = this;" + 68 "" + 69 " if (window.addEventListener)" + 70 " {" + 71 " window.addEventListener('DOMMouseScroll', MouseWheelSupport.instance.wheel, false);" + 72 " }" + 73 " window.onmousewheel = document.onmousewheel = MouseWheelSupport.instance.wheel;" + 74 " }," + 75 "" + 76 " handle: function (delta, mouseX, mouseY)" + 77 " {" + 78 " this.swf.dispatchMouseWheelEvent(delta, mouseX, mouseY);" + 79 " }," + 80 "" + 81 " wheel: function (event)" + 82 " {" + 83 " var delta = 0;" + 84 " var mouseX;" + 85 " var mouseY;" + 86 "" + 87 " if (event.wheelDelta)" + 88 " {" + 89 " delta = Math.round(event.wheelDelta / 80);" + 90 " if (window.opera)" + 91 " delta = -delta;" + 92 " }" + 93 " else if (event.detail)" + 94 " {" + 95 " delta = -event.detail / 3;" + 96 " }" + 97 "" + 98 " if (/AppleWebKit/.test(navigator.userAgent))" + 99 " delta /= 3;" + 100 "" + 101 " if ((navigator.userAgent.indexOf('Firefox') > -1) ||" + 102 " (navigator.userAgent.indexOf('Camino') > -1))" + 103 " {" + 104 " mouseX = event.layerX;" + 105 " mouseY = event.layerY;" + 106 " }" + 107 " else" + 108 " {" + 109 " mouseX = event.offsetX;" + 110 " mouseY = event.offsetY;" + 111 " }" + 112 "" + 113 " if (delta)" + 114 " MouseWheelSupport.instance.handle(delta, mouseX, mouseY);" + 115 "" + 116 " if (event.preventDefault)" + 117 " event.preventDefault();" + 118 "" + 119 " event.returnValue = false;" + 120 " }" + 121 " };" + 122 "" + 123 " new MouseWheelSupport(document[objectID]);" + 124 "}"; 125 126 //-------------------------------------------------------------------------- 127 // 52 128 // Class properties 53 129 // … … 84 160 initialize(); 85 161 } 86 87 //--------------------------------------------------------------------------88 //89 // Variables90 //91 //--------------------------------------------------------------------------92 93 /**94 * @private95 */96 private var lastTime:int;97 98 /**99 * @private100 */101 private var lastDelta:int;102 103 /**104 * @private105 */106 private var irregularCount:int;107 162 108 163 //-------------------------------------------------------------------------- … … 122 177 { 123 178 ExternalInterface.addCallback("dispatchMouseWheelEvent", mouseWheelHandler); 124 ExternalInterface.call( "initializeMouseWheel");179 ExternalInterface.call(js, ExternalInterface.objectID); 125 180 } 126 181 } 127 182 } 128 183 184 private function calcurateDelta(value:Number):Number 185 { 186 var delta:Number; 187 188 if (value < 1 && value > 0) 189 delta = 1; 190 else if (value > -1 && value < 0) 191 delta = -1; 192 else 193 delta = value; 194 195 return delta; 196 } 197 198 //-------------------------------------------------------------------------- 199 // 200 // Event handlers 201 // 202 //-------------------------------------------------------------------------- 203 129 204 /** 130 205 * @private 131 206 */ 132 private function validateDelta(delta:int):int 133 { 134 var currentTime:int = getTimer(); 135 var interval:int = currentTime - lastTime; 136 lastTime = currentTime; 207 private function mouseWheelHandler(delta:Number, mouseX:Number, mouseY:Number):void 208 { 209 delta = calcurateDelta(delta); 137 210 138 if (delta != lastDelta) 139 { 140 if (irregularCount > 2 || interval > 200) { 141 lastDelta = delta; 142 irregularCount = 0; 143 } 144 else 145 { 146 delta = lastDelta; 147 irregularCount++; 148 } 149 } 150 151 var speed:int = (interval < 1000) ? 1000 / interval : 1; 152 var validatedDelta:int = (speed > 1200 ? 120 : speed) * delta * 0.1; 153 return validatedDelta === 0 ? delta : validatedDelta; 154 } 155 156 //-------------------------------------------------------------------------- 157 // 158 // Event handlers 159 // 160 //-------------------------------------------------------------------------- 161 162 /** 163 * @private 164 */ 165 private function mouseWheelHandler(delta:int, mouseX:Number, mouseY:Number):void 166 { 167 var validatedDelta:int = validateDelta(delta); 168 var stage:Stage = Application.application.stage; 211 var stage:Stage = Application.application.systemManager.stage; 169 212 var items:Array = stage.getObjectsUnderPoint(new Point(mouseX, mouseY)); 170 213 for each (var item:DisplayObject in items) … … 175 218 if (item is TextArea) { 176 219 var textArea:TextArea = item as TextArea; 177 textArea.verticalScrollPosition -= validatedDelta / 6;220 textArea.verticalScrollPosition -= delta; 178 221 } 179 222 else if (item is Canvas || item is ListBase) 180 223 { 181 var wheelEvent:MouseEvent = new MouseEvent( 182 MouseEvent.MOUSE_WHEEL, 183 true, 184 false, 185 NaN, 186 NaN, 187 null, 188 false, 189 false, 190 false, 191 false, 192 validatedDelta 193 ); 224 var wheelEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_WHEEL); 225 wheelEvent.delta = delta; 194 226 item.dispatchEvent(wheelEvent); 195 227 }

