add way to enable browser scrolling
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/fdd2e6b9 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/fdd2e6b9 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/fdd2e6b9 Branch: refs/heads/develop Commit: fdd2e6b921c8741e69c524ce4cd364b4b21c89de Parents: 51f8ce2 Author: Alex Harui <[email protected]> Authored: Thu Sep 3 11:45:48 2015 -0700 Committer: Alex Harui <[email protected]> Committed: Thu Sep 3 11:46:42 2015 -0700 ---------------------------------------------------------------------- .../flexjs/ChartExample/src/ChartExample.mxml | 4 +- .../src/org/apache/flex/core/BrowserScroller.as | 81 ++++++++++++++++++++ frameworks/projects/Core/basic-manifest.xml | 1 + .../src/org/apache/flex/core/BrowserScroller.js | 55 +++++++++++++ 4 files changed, 140 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fdd2e6b9/examples/flexjs/ChartExample/src/ChartExample.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/ChartExample/src/ChartExample.mxml b/examples/flexjs/ChartExample/src/ChartExample.mxml index 6cf51d9..57bc2a4 100644 --- a/examples/flexjs/ChartExample/src/ChartExample.mxml +++ b/examples/flexjs/ChartExample/src/ChartExample.mxml @@ -23,7 +23,9 @@ xmlns:models="models.*" xmlns:js="library://ns.apache.org/flexjs/basic" > - + <js:beads> + <js:BrowserScroller /> + </js:beads> <js:valuesImpl> <js:SimpleCSSValuesImpl /> </js:valuesImpl> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fdd2e6b9/frameworks/projects/Core/as/src/org/apache/flex/core/BrowserScroller.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/BrowserScroller.as b/frameworks/projects/Core/as/src/org/apache/flex/core/BrowserScroller.as new file mode 100644 index 0000000..355453a --- /dev/null +++ b/frameworks/projects/Core/as/src/org/apache/flex/core/BrowserScroller.as @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.core +{ + import flash.external.ExternalInterface; + import flash.utils.getQualifiedClassName; + + import org.apache.flex.events.Event; + + /** + * The BrowserScroller class enables browser scrollbars + * when the application is larger than the screen. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class BrowserScroller implements IBead + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function BrowserScroller() + { + } + + private var app:Application; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function set strand(value:IStrand):void + { + app = value as Application; + app.addEventListener("viewChanged", viewChangedHandler); + } + + private function viewChangedHandler(event:Event):void + { + // some day also listen to initial view for size changes + if (ExternalInterface.available) + { + // Get application name. This assumes that the wrapper is using an + // object tag with the id that matches the application name + var appName:String = getQualifiedClassName(app); + var js:String = "var o = document.getElementById('" + appName + "');"; + js += "o.width = " + app.initialView.width.toString() + ";"; + js += "o.height = " + app.initialView.height.toString() + ";" + ExternalInterface.call("eval", js); + } + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fdd2e6b9/frameworks/projects/Core/basic-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/basic-manifest.xml b/frameworks/projects/Core/basic-manifest.xml index 995157d..65f0db8 100644 --- a/frameworks/projects/Core/basic-manifest.xml +++ b/frameworks/projects/Core/basic-manifest.xml @@ -22,6 +22,7 @@ <componentPackage> <component id="Application" class="org.apache.flex.core.Application"/> + <component id="BrowserScroller" class="org.apache.flex.core.BrowserScroller"/> <component id="SimpleValuesImpl" class="org.apache.flex.core.SimpleValuesImpl"/> <component id="SimpleCSSValuesImpl" class="org.apache.flex.core.SimpleCSSValuesImpl"/> <component id="ViewBase" class="org.apache.flex.core.ViewBase"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/fdd2e6b9/frameworks/projects/Core/js/src/org/apache/flex/core/BrowserScroller.js ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/BrowserScroller.js b/frameworks/projects/Core/js/src/org/apache/flex/core/BrowserScroller.js new file mode 100644 index 0000000..e6a4987 --- /dev/null +++ b/frameworks/projects/Core/js/src/org/apache/flex/core/BrowserScroller.js @@ -0,0 +1,55 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.core.BrowserScroller'); + + + +/** + * @constructor + */ +org.apache.flex.core.BrowserScroller = function() { + this.strand_ = null; +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +org.apache.flex.core.BrowserScroller.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'BrowserScroller', + qName: 'org.apache.flex.core.BrowserScroller'}]}; + + +/** + * @param {Event} e The event. + */ +org.apache.flex.core.BrowserScroller.prototype.viewChangedHandler = function(e) { + this.strand_.element.style.overflow = 'auto'; +}; + + +Object.defineProperties(org.apache.flex.core.BrowserScroller.prototype, { + /** @export */ + strand: { + /** @this {org.apache.flex.core.BrowserScroller} */ + set: function(value) { + this.strand_ = value; + value.addEventListener('viewChanged', + goog.bind(this.viewChangedHandler, this)); + } + } +});
