@openui5/sap.ui.core 1.136.4 → 1.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +3 -3
- package/README.md +1 -1
- package/REUSE.toml +8 -29
- package/THIRDPARTY.txt +72 -90
- package/package.json +2 -2
- package/src/jquery.sap.global.js +1 -1
- package/src/jquery.sap.properties.js +1 -1
- package/src/jquery.sap.resources.js +1 -1
- package/src/jquery.sap.script.js +1 -1
- package/src/jquery.sap.storage.js +3 -3
- package/src/sap/base/Event.js +1 -1
- package/src/sap/base/Eventing.js +1 -1
- package/src/sap/base/config.js +1 -1
- package/src/sap/base/i18n/LanguageFallback.js +18 -2
- package/src/sap/base/i18n/LanguageTag.js +1 -1
- package/src/sap/base/i18n/Localization.js +5 -3
- package/src/sap/base/i18n/ResourceBundle.js +59 -35
- package/src/sap/base/i18n/date/TimezoneUtils.js +1 -1
- package/src/sap/base/util/restricted/_CancelablePromise.js +1 -1
- package/src/sap/base/util/restricted/_castArray.js +1 -1
- package/src/sap/base/util/restricted/_compact.js +1 -1
- package/src/sap/base/util/restricted/_curry.js +1 -1
- package/src/sap/base/util/restricted/_debounce.js +1 -1
- package/src/sap/base/util/restricted/_difference.js +1 -1
- package/src/sap/base/util/restricted/_differenceBy.js +1 -1
- package/src/sap/base/util/restricted/_differenceWith.js +1 -1
- package/src/sap/base/util/restricted/_flatMap.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDeep.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDepth.js +1 -1
- package/src/sap/base/util/restricted/_flatten.js +1 -1
- package/src/sap/base/util/restricted/_flattenDeep.js +1 -1
- package/src/sap/base/util/restricted/_flattenDepth.js +1 -1
- package/src/sap/base/util/restricted/_intersection.js +1 -1
- package/src/sap/base/util/restricted/_intersectionBy.js +1 -1
- package/src/sap/base/util/restricted/_intersectionWith.js +1 -1
- package/src/sap/base/util/restricted/_isEqual.js +1 -1
- package/src/sap/base/util/restricted/_isEqualWith.js +1 -1
- package/src/sap/base/util/restricted/_isNil.js +1 -1
- package/src/sap/base/util/restricted/_max.js +1 -1
- package/src/sap/base/util/restricted/_merge.js +1 -1
- package/src/sap/base/util/restricted/_mergeWith.js +1 -1
- package/src/sap/base/util/restricted/_min.js +1 -1
- package/src/sap/base/util/restricted/_omit.js +1 -1
- package/src/sap/base/util/restricted/_pick.js +1 -1
- package/src/sap/base/util/restricted/_pickBy.js +1 -1
- package/src/sap/base/util/restricted/_throttle.js +1 -1
- package/src/sap/base/util/restricted/_toArray.js +1 -1
- package/src/sap/base/util/restricted/_union.js +1 -1
- package/src/sap/base/util/restricted/_unionBy.js +1 -1
- package/src/sap/base/util/restricted/_unionWith.js +1 -1
- package/src/sap/base/util/restricted/_uniq.js +1 -1
- package/src/sap/base/util/restricted/_uniqBy.js +1 -1
- package/src/sap/base/util/restricted/_uniqWith.js +1 -1
- package/src/sap/base/util/restricted/_without.js +1 -1
- package/src/sap/base/util/restricted/_xor.js +1 -1
- package/src/sap/base/util/restricted/_xorBy.js +1 -1
- package/src/sap/base/util/restricted/_xorWith.js +1 -1
- package/src/sap/base/util/restricted/_zipObject.js +1 -1
- package/src/sap/base/util/restricted/_zipObjectDeep.js +1 -1
- package/src/sap/ui/Device.js +3 -3
- package/src/sap/ui/Global.js +3 -3
- package/src/sap/ui/base/BindingInfo.js +18 -9
- package/src/sap/ui/base/BindingParser.js +13 -6
- package/src/sap/ui/base/Event.js +1 -1
- package/src/sap/ui/base/EventProvider.js +1 -8
- package/src/sap/ui/base/Interface.js +1 -1
- package/src/sap/ui/base/ManagedObject.js +37 -27
- package/src/sap/ui/base/ManagedObjectMetadata.js +1 -1
- package/src/sap/ui/base/Metadata.js +1 -1
- package/src/sap/ui/base/Object.js +1 -1
- package/src/sap/ui/base/ObjectPool.js +1 -1
- package/src/sap/ui/base/OwnStatics.js +49 -0
- package/src/sap/ui/core/.library +9 -31
- package/src/sap/ui/core/BusyIndicator.js +8 -8
- package/src/sap/ui/core/Component.js +63 -73
- package/src/sap/ui/core/ComponentContainer.js +34 -4
- package/src/sap/ui/core/ComponentMetadata.js +1 -1
- package/src/sap/ui/core/ComponentSupport.js +1 -1
- package/src/sap/ui/core/Configuration.js +1 -1
- package/src/sap/ui/core/Control.js +1 -1
- package/src/sap/ui/core/Core.js +2 -2
- package/src/sap/ui/core/CustomData.js +1 -1
- package/src/sap/ui/core/DeclarativeSupport.js +13 -11
- package/src/sap/ui/core/Element.js +1 -3
- package/src/sap/ui/core/ElementMetadata.js +1 -1
- package/src/sap/ui/core/EnabledPropagator.js +1 -1
- package/src/sap/ui/core/EventBus.js +1 -1
- package/src/sap/ui/core/ExtensionPoint.js +4 -4
- package/src/sap/ui/core/Fragment.js +10 -6
- package/src/sap/ui/core/HTML.js +1 -1
- package/src/sap/ui/core/History.js +1 -1
- package/src/sap/ui/core/Icon.js +1 -1
- package/src/sap/ui/core/IndicationColorSupport.js +1 -1
- package/src/sap/ui/core/IntervalTrigger.js +1 -1
- package/src/sap/ui/core/InvisibleMessage.js +1 -1
- package/src/sap/ui/core/InvisibleRenderer.js +1 -1
- package/src/sap/ui/core/InvisibleText.js +1 -1
- package/src/sap/ui/core/Item.js +1 -1
- package/src/sap/ui/core/LabelEnablement.js +1 -1
- package/src/sap/ui/core/LayoutData.js +1 -1
- package/src/sap/ui/core/Lib.js +39 -24
- package/src/sap/ui/core/ListItem.js +1 -1
- package/src/sap/ui/core/LocalBusyIndicator.js +1 -1
- package/src/sap/ui/core/Locale.js +1 -1
- package/src/sap/ui/core/LocaleData.js +1 -1
- package/src/sap/ui/core/Manifest.js +1 -1
- package/src/sap/ui/core/Message.js +1 -1
- package/src/sap/ui/core/Popup.js +39 -178
- package/src/sap/ui/core/RenderManager.js +1 -1
- package/src/sap/ui/core/Renderer.js +1 -1
- package/src/sap/ui/core/ResizeHandler.js +1 -1
- package/src/sap/ui/core/ScrollBar.js +1 -1
- package/src/sap/ui/core/SeparatorItem.js +1 -1
- package/src/sap/ui/core/Theming.js +2 -2
- package/src/sap/ui/core/Title.js +1 -1
- package/src/sap/ui/core/TooltipBase.js +1 -1
- package/src/sap/ui/core/UIArea.js +1 -1
- package/src/sap/ui/core/UIComponent.js +16 -57
- package/src/sap/ui/core/UIComponentMetadata.js +1 -1
- package/src/sap/ui/core/ValueStateSupport.js +1 -1
- package/src/sap/ui/core/VariantLayoutData.js +1 -1
- package/src/sap/ui/core/XMLComposite.js +1 -1
- package/src/sap/ui/core/XMLCompositeMetadata.js +1 -1
- package/src/sap/ui/core/XMLTemplateProcessor.js +5 -1
- package/src/sap/ui/core/_IconRegistry.js +2 -0
- package/src/sap/ui/core/date/UI5Date.js +1 -1
- package/src/sap/ui/core/delegate/ItemNavigation.js +2 -2
- package/src/sap/ui/core/delegate/ScrollEnablement.js +1 -1
- package/src/sap/ui/core/dnd/DragDropBase.js +12 -2
- package/src/sap/ui/core/dnd/DragDropInfo.js +1 -1
- package/src/sap/ui/core/dnd/DragInfo.js +5 -3
- package/src/sap/ui/core/dnd/DropInfo.js +1 -1
- package/src/sap/ui/core/format/FormatUtils.js +1 -1
- package/src/sap/ui/core/format/TimezoneUtil.js +1 -1
- package/src/sap/ui/core/getCompatibilityVersion.js +1 -1
- package/src/sap/ui/core/hyphenation/Hyphenation.js +1 -1
- package/src/sap/ui/core/interaction/KeyboardInteractionDisplay.js +64 -37
- package/src/sap/ui/core/library.js +3 -3
- package/src/sap/ui/core/message/ControlMessageProcessor.js +1 -1
- package/src/sap/ui/core/message/Message.js +1 -1
- package/src/sap/ui/core/message/MessageManager.js +1 -1
- package/src/sap/ui/core/message/MessageParser.js +1 -1
- package/src/sap/ui/core/message/MessageProcessor.js +6 -6
- package/src/sap/ui/core/messagebundle.properties +58 -28
- package/src/sap/ui/core/messagebundle_mk.properties +3 -3
- package/src/sap/ui/core/mvc/Controller.js +5 -1
- package/src/sap/ui/core/mvc/HTMLView.js +6 -2
- package/src/sap/ui/core/mvc/JSONView.js +6 -2
- package/src/sap/ui/core/mvc/JSView.js +6 -3
- package/src/sap/ui/core/mvc/TemplateView.js +1 -1
- package/src/sap/ui/core/mvc/View.js +69 -195
- package/src/sap/ui/core/mvc/XMLView.js +7 -2
- package/src/sap/ui/core/mvc/_ViewFactory.js +196 -0
- package/src/sap/ui/core/plugin/DeclarativeSupport.js +1 -1
- package/src/sap/ui/core/plugin/LessSupport.js +1 -1
- package/src/sap/ui/core/plugin/TemplatingSupport.js +1 -1
- package/src/sap/ui/core/postmessage/Bus.js +1 -1
- package/src/sap/ui/core/postmessage/confirmationDialog.js +1 -1
- package/src/sap/ui/core/routing/Route.js +197 -13
- package/src/sap/ui/core/routing/Router.js +19 -8
- package/src/sap/ui/core/routing/RouterHashChanger.js +12 -3
- package/src/sap/ui/core/routing/Target.js +714 -61
- package/src/sap/ui/core/routing/TargetCache.js +205 -25
- package/src/sap/ui/core/routing/Targets.js +162 -67
- package/src/sap/ui/core/routing/Views.js +1 -0
- package/src/sap/ui/core/routing/sync/Route.js +1 -1
- package/src/sap/ui/core/routing/sync/Target.js +11 -1
- package/src/sap/ui/core/routing/sync/TargetCache.js +3 -3
- package/src/sap/ui/core/routing/sync/Targets.js +1 -1
- package/src/sap/ui/core/search/OpenSearchProvider.js +1 -1
- package/src/sap/ui/core/search/SearchProvider.js +1 -1
- package/src/sap/ui/core/service/Service.js +1 -48
- package/src/sap/ui/core/service/ServiceFactory.js +44 -4
- package/src/sap/ui/core/service/ServiceFactoryRegistry.js +1 -1
- package/src/sap/ui/core/support/Plugin.js +1 -1
- package/src/sap/ui/core/support/Support.js +356 -353
- package/src/sap/ui/core/support/plugins/ControlTree.js +1 -1
- package/src/sap/ui/core/support/plugins/Interaction.js +1 -1
- package/src/sap/ui/core/support/plugins/LocalStorage.js +1 -1
- package/src/sap/ui/core/support/plugins/Performance.js +1 -1
- package/src/sap/ui/core/support/plugins/Selector.js +1 -1
- package/src/sap/ui/core/support/plugins/TechInfo.js +1 -1
- package/src/sap/ui/core/support/plugins/Trace.js +1 -1
- package/src/sap/ui/core/support/plugins/ViewInfo.js +4 -2
- package/src/sap/ui/core/themes/base/base.less +20 -20
- package/src/sap/ui/core/themes/base/fonts/SAP-icons.ttf +0 -0
- package/src/sap/ui/core/themes/base/fonts/SAP-icons.woff2 +0 -0
- package/src/sap/ui/core/themes/base/global.less +4 -0
- package/src/sap/ui/core/themes/base/skeleton.less +3 -3
- package/src/sap/ui/core/theming/ThemeHelper.js +1 -18
- package/src/sap/ui/core/tmpl/DOMAttribute.js +1 -1
- package/src/sap/ui/core/tmpl/DOMElement.js +1 -1
- package/src/sap/ui/core/tmpl/HandlebarsTemplate.js +4 -4
- package/src/sap/ui/core/tmpl/Template.js +1 -1
- package/src/sap/ui/core/tmpl/TemplateControl.js +1 -1
- package/src/sap/ui/core/util/AsyncHintsHelper.js +1 -1
- package/src/sap/ui/core/util/Export.js +1 -1
- package/src/sap/ui/core/util/ExportCell.js +1 -1
- package/src/sap/ui/core/util/ExportColumn.js +1 -1
- package/src/sap/ui/core/util/ExportRow.js +1 -1
- package/src/sap/ui/core/util/ExportType.js +1 -1
- package/src/sap/ui/core/util/ExportTypeCSV.js +1 -1
- package/src/sap/ui/core/util/File.js +1 -1
- package/src/sap/ui/core/util/LibraryInfo.js +1 -1
- package/src/sap/ui/core/util/MockServer.js +1 -1
- package/src/sap/ui/core/util/PasteHelper.js +1 -1
- package/src/sap/ui/core/util/XMLPreprocessor.js +8 -1
- package/src/sap/ui/core/util/reflection/XmlTreeModifier.js +4 -4
- package/src/sap/ui/core/util/serializer/HTMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/Serializer.js +1 -1
- package/src/sap/ui/core/util/serializer/ViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/XMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/Delegate.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/HTML.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/XML.js +1 -1
- package/src/sap/ui/core/webc/WebComponent.js +2 -3
- package/src/sap/ui/core/webc/WebComponentMetadata.js +2 -3
- package/src/sap/ui/core/webc/WebComponentRenderer.js +1 -1
- package/src/sap/ui/core/ws/ReadyState.js +1 -1
- package/src/sap/ui/core/ws/SapPcpWebSocket.js +1 -1
- package/src/sap/ui/core/ws/WebSocket.js +1 -1
- package/src/sap/ui/debug/ControlTree.js +1 -1
- package/src/sap/ui/debug/DebugEnv.js +1 -1
- package/src/sap/ui/debug/PropertyList.js +1 -1
- package/src/sap/ui/model/ClientModel.js +2 -2
- package/src/sap/ui/model/CompositeDataState.js +1 -1
- package/src/sap/ui/model/CompositeType.js +1 -1
- package/src/sap/ui/model/DataState.js +1 -1
- package/src/sap/ui/model/Filter.js +55 -35
- package/src/sap/ui/model/FilterOperator.js +79 -9
- package/src/sap/ui/model/MetaModel.js +1 -1
- package/src/sap/ui/model/Model.js +1 -1
- package/src/sap/ui/model/SelectionModel.js +1 -1
- package/src/sap/ui/model/SimpleType.js +1 -1
- package/src/sap/ui/model/TreeAutoExpandMode.js +1 -1
- package/src/sap/ui/model/Type.js +1 -1
- package/src/sap/ui/model/analytics/AnalyticalBinding.js +2 -1
- package/src/sap/ui/model/analytics/AnalyticalTreeBindingAdapter.js +2 -1
- package/src/sap/ui/model/analytics/ODataModelAdapter.js +2 -1
- package/src/sap/ui/model/analytics/odata4analytics.js +2 -1
- package/src/sap/ui/model/json/JSONModel.js +1 -1
- package/src/sap/ui/model/message/MessageModel.js +1 -1
- package/src/sap/ui/model/odata/ODataAnnotations.js +1 -1
- package/src/sap/ui/model/odata/ODataMessageParser.js +1 -1
- package/src/sap/ui/model/odata/ODataMetaModel.js +1 -1
- package/src/sap/ui/model/odata/ODataMetadata.js +1 -1
- package/src/sap/ui/model/odata/ODataModel.js +3 -3
- package/src/sap/ui/model/odata/ODataTreeBindingAdapter.js +2 -1
- package/src/sap/ui/model/odata/_AnnotationHelperExpression.js +3 -3
- package/src/sap/ui/model/odata/type/Boolean.js +1 -1
- package/src/sap/ui/model/odata/type/Byte.js +1 -1
- package/src/sap/ui/model/odata/type/Currency.js +1 -1
- package/src/sap/ui/model/odata/type/Date.js +1 -1
- package/src/sap/ui/model/odata/type/DateTime.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeBase.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeOffset.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeWithTimezone.js +1 -1
- package/src/sap/ui/model/odata/type/Decimal.js +1 -1
- package/src/sap/ui/model/odata/type/Double.js +1 -1
- package/src/sap/ui/model/odata/type/Guid.js +1 -1
- package/src/sap/ui/model/odata/type/Int.js +1 -1
- package/src/sap/ui/model/odata/type/Int16.js +1 -1
- package/src/sap/ui/model/odata/type/Int32.js +1 -1
- package/src/sap/ui/model/odata/type/Int64.js +1 -1
- package/src/sap/ui/model/odata/type/ODataType.js +1 -1
- package/src/sap/ui/model/odata/type/Raw.js +1 -1
- package/src/sap/ui/model/odata/type/SByte.js +1 -1
- package/src/sap/ui/model/odata/type/Single.js +1 -1
- package/src/sap/ui/model/odata/type/Stream.js +1 -1
- package/src/sap/ui/model/odata/type/String.js +1 -1
- package/src/sap/ui/model/odata/type/Time.js +1 -1
- package/src/sap/ui/model/odata/type/TimeOfDay.js +1 -1
- package/src/sap/ui/model/odata/type/Unit.js +1 -1
- package/src/sap/ui/model/odata/v2/Context.js +1 -1
- package/src/sap/ui/model/odata/v2/ODataAnnotations.js +1 -1
- package/src/sap/ui/model/odata/v2/ODataModel.js +2 -2
- package/src/sap/ui/model/odata/v2/ODataTreeBinding.js +1 -1
- package/src/sap/ui/model/odata/v4/Context.js +20 -17
- package/src/sap/ui/model/odata/v4/ODataBinding.js +2 -2
- package/src/sap/ui/model/odata/v4/ODataContextBinding.js +4 -4
- package/src/sap/ui/model/odata/v4/ODataListBinding.js +34 -22
- package/src/sap/ui/model/odata/v4/ODataMetaModel.js +60 -22
- package/src/sap/ui/model/odata/v4/ODataModel.js +9 -8
- package/src/sap/ui/model/odata/v4/ODataParentBinding.js +2 -2
- package/src/sap/ui/model/odata/v4/ODataPropertyBinding.js +1 -1
- package/src/sap/ui/model/odata/v4/ODataUtils.js +2 -2
- package/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js +4 -4
- package/src/sap/ui/model/odata/v4/lib/_AggregationCache.js +98 -89
- package/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js +39 -7
- package/src/sap/ui/model/odata/v4/lib/_Cache.js +32 -26
- package/src/sap/ui/model/odata/v4/lib/_GroupLock.js +10 -4
- package/src/sap/ui/model/odata/v4/lib/_Helper.js +44 -24
- package/src/sap/ui/model/odata/v4/lib/_MinMaxHelper.js +1 -1
- package/src/sap/ui/model/odata/v4/lib/_Requestor.js +50 -19
- package/src/sap/ui/model/odata/v4/lib/_V2Requestor.js +1 -1
- package/src/sap/ui/model/resource/ResourceModel.js +1 -1
- package/src/sap/ui/model/type/Boolean.js +1 -1
- package/src/sap/ui/model/type/Currency.js +1 -1
- package/src/sap/ui/model/type/Date.js +1 -1
- package/src/sap/ui/model/type/DateInterval.js +1 -1
- package/src/sap/ui/model/type/DateTime.js +1 -1
- package/src/sap/ui/model/type/DateTimeInterval.js +1 -1
- package/src/sap/ui/model/type/FileSize.js +1 -1
- package/src/sap/ui/model/type/Float.js +1 -1
- package/src/sap/ui/model/type/Integer.js +1 -1
- package/src/sap/ui/model/type/String.js +1 -1
- package/src/sap/ui/model/type/Time.js +1 -1
- package/src/sap/ui/model/type/TimeInterval.js +1 -1
- package/src/sap/ui/model/type/Unit.js +1 -4
- package/src/sap/ui/model/xml/XMLModel.js +1 -1
- package/src/sap/ui/qunit/utils/ControlIterator.js +1 -1
- package/src/sap/ui/qunit/utils/MemoryLeakCheck.js +1 -1
- package/src/sap/ui/test/Opa.js +14 -2
- package/src/sap/ui/test/Opa5.js +61 -10
- package/src/sap/ui/test/TestUtils.js +6 -2
- package/src/sap/ui/test/generic/GenericTestCollection.js +11 -1
- package/src/sap/ui/test/generic/TestBase.js +1 -1
- package/src/sap/ui/thirdparty/datajs.js +13 -10
- package/src/sap/ui/thirdparty/jquery.js +1 -1
- package/src/sap/ui/util/Storage.js +1 -1
- package/src/ui5loader-autoconfig.js +49 -59
- package/src/ui5loader.js +1 -1
- package/src/sap/ui/core/routing/async/Route.js +0 -186
- package/src/sap/ui/core/routing/async/Target.js +0 -712
- package/src/sap/ui/core/routing/async/TargetCache.js +0 -196
- package/src/sap/ui/core/routing/async/Targets.js +0 -130
- package/src/sap/ui/thirdparty/iscroll-lite.js +0 -603
- package/src/sap/ui/thirdparty/iscroll.js +0 -1104
- package/src/sap/ui/thirdparty/mobiscroll/css/mobiscroll-core.css +0 -416
- package/src/sap/ui/thirdparty/mobiscroll/js/mobiscroll-core.js +0 -127
- package/src/sap/ui/thirdparty/mobiscroll/js/mobiscroll-datetime.js +0 -818
- package/src/sap/ui/thirdparty/mobiscroll/js/mobiscroll-scroller.js +0 -1264
- package/src/sap/ui/thirdparty/swipe-view.js +0 -560
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* iScroll Lite base on iScroll v4.1.6 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org
|
|
3
|
-
* Released under MIT license, http://cubiq.org/license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
(function(){
|
|
7
|
-
var m = Math,
|
|
8
|
-
mround = function (r) { return r >> 0; },
|
|
9
|
-
vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' :
|
|
10
|
-
(/firefox/i).test(navigator.userAgent) ? 'Moz' :
|
|
11
|
-
'opera' in window ? 'O' : '',
|
|
12
|
-
|
|
13
|
-
// Browser capabilities
|
|
14
|
-
isAndroid = (/android/gi).test(navigator.appVersion),
|
|
15
|
-
isIDevice = (/iphone|ipad/gi).test(navigator.appVersion),
|
|
16
|
-
isPlaybook = (/playbook/gi).test(navigator.appVersion),
|
|
17
|
-
isTouchPad = (/hp-tablet/gi).test(navigator.appVersion),
|
|
18
|
-
|
|
19
|
-
has3d = 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix(),
|
|
20
|
-
hasTouch = 'ontouchstart' in window && !isTouchPad,
|
|
21
|
-
hasTransform = vendor + 'Transform' in document.documentElement.style,
|
|
22
|
-
hasTransitionEnd = isIDevice || isPlaybook,
|
|
23
|
-
|
|
24
|
-
nextFrame = (function() {
|
|
25
|
-
return window.requestAnimationFrame
|
|
26
|
-
|| window.webkitRequestAnimationFrame
|
|
27
|
-
|| window.mozRequestAnimationFrame
|
|
28
|
-
|| window.oRequestAnimationFrame
|
|
29
|
-
|| window.msRequestAnimationFrame
|
|
30
|
-
|| function(callback) { return setTimeout(callback, 17); }
|
|
31
|
-
})(),
|
|
32
|
-
cancelFrame = (function () {
|
|
33
|
-
return window.cancelRequestAnimationFrame
|
|
34
|
-
|| window.webkitCancelAnimationFrame
|
|
35
|
-
|| window.webkitCancelRequestAnimationFrame
|
|
36
|
-
|| window.mozCancelRequestAnimationFrame
|
|
37
|
-
|| window.oCancelRequestAnimationFrame
|
|
38
|
-
|| window.msCancelRequestAnimationFrame
|
|
39
|
-
|| clearTimeout
|
|
40
|
-
})(),
|
|
41
|
-
|
|
42
|
-
// Events
|
|
43
|
-
RESIZE_EV = 'onorientationchange' in window ? 'orientationchange' : 'resize',
|
|
44
|
-
START_EV = hasTouch ? 'touchstart' : 'mousedown',
|
|
45
|
-
MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
|
|
46
|
-
END_EV = hasTouch ? 'touchend' : 'mouseup',
|
|
47
|
-
CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup',
|
|
48
|
-
|
|
49
|
-
// Helpers
|
|
50
|
-
trnOpen = 'translate' + (has3d ? '3d(' : '('),
|
|
51
|
-
trnClose = has3d ? ',0)' : ')',
|
|
52
|
-
|
|
53
|
-
// Constructor
|
|
54
|
-
iScroll = function (el, options) {
|
|
55
|
-
var that = this,
|
|
56
|
-
doc = document,
|
|
57
|
-
i;
|
|
58
|
-
|
|
59
|
-
that.wrapper = typeof el == 'object' ? el : doc.getElementById(el);
|
|
60
|
-
that.wrapper.style.overflow = 'hidden';
|
|
61
|
-
that.scroller = that.wrapper.children[0];
|
|
62
|
-
|
|
63
|
-
// Default options
|
|
64
|
-
that.options = {
|
|
65
|
-
hScroll: true,
|
|
66
|
-
vScroll: true,
|
|
67
|
-
x: 0,
|
|
68
|
-
y: 0,
|
|
69
|
-
bounce: true,
|
|
70
|
-
bounceLock: false,
|
|
71
|
-
momentum: true,
|
|
72
|
-
lockDirection: true,
|
|
73
|
-
useTransform: true,
|
|
74
|
-
useTransition: false,
|
|
75
|
-
|
|
76
|
-
// Events
|
|
77
|
-
onRefresh: null,
|
|
78
|
-
onBeforeScrollStart: function (e) { e.preventDefault(); },
|
|
79
|
-
onScrollStart: null,
|
|
80
|
-
onBeforeScrollMove: null,
|
|
81
|
-
onScrollMove: null,
|
|
82
|
-
onBeforeScrollEnd: null,
|
|
83
|
-
onScrollEnd: null,
|
|
84
|
-
onTouchEnd: null,
|
|
85
|
-
onDestroy: null
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// User defined options
|
|
89
|
-
for (i in options) that.options[i] = options[i];
|
|
90
|
-
|
|
91
|
-
// Set starting position
|
|
92
|
-
that.x = that.options.x;
|
|
93
|
-
that.y = that.options.y;
|
|
94
|
-
|
|
95
|
-
// Normalize options
|
|
96
|
-
that.options.useTransform = hasTransform ? that.options.useTransform : false;
|
|
97
|
-
that.options.hScrollbar = that.options.hScroll && that.options.hScrollbar;
|
|
98
|
-
that.options.vScrollbar = that.options.vScroll && that.options.vScrollbar;
|
|
99
|
-
that.options.useTransition = hasTransitionEnd && that.options.useTransition;
|
|
100
|
-
|
|
101
|
-
// Set some default styles
|
|
102
|
-
that.scroller.style[vendor + 'TransitionProperty'] = that.options.useTransform ? '-' + vendor.toLowerCase() + '-transform' : 'top left';
|
|
103
|
-
that.scroller.style[vendor + 'TransitionDuration'] = '0';
|
|
104
|
-
that.scroller.style[vendor + 'TransformOrigin'] = '0 0';
|
|
105
|
-
if (that.options.useTransition) that.scroller.style[vendor + 'TransitionTimingFunction'] = 'cubic-bezier(0.33,0.66,0.66,1)';
|
|
106
|
-
|
|
107
|
-
if (that.options.useTransform) that.scroller.style[vendor + 'Transform'] = trnOpen + that.x + 'px,' + that.y + 'px' + trnClose;
|
|
108
|
-
else that.scroller.style.cssText += ';position:absolute;top:' + that.y + 'px;left:' + that.x + 'px';
|
|
109
|
-
|
|
110
|
-
that.refresh();
|
|
111
|
-
|
|
112
|
-
that._bind(RESIZE_EV, window);
|
|
113
|
-
that._bind(START_EV);
|
|
114
|
-
if (!hasTouch) that._bind('mouseout', that.wrapper);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// Prototype
|
|
118
|
-
iScroll.prototype = {
|
|
119
|
-
enabled: true,
|
|
120
|
-
x: 0,
|
|
121
|
-
y: 0,
|
|
122
|
-
steps: [],
|
|
123
|
-
scale: 1,
|
|
124
|
-
|
|
125
|
-
handleEvent: function (e) {
|
|
126
|
-
var that = this;
|
|
127
|
-
switch(e.type) {
|
|
128
|
-
case START_EV:
|
|
129
|
-
if (!hasTouch && e.button !== 0) return;
|
|
130
|
-
that._start(e);
|
|
131
|
-
break;
|
|
132
|
-
case MOVE_EV: that._move(e); break;
|
|
133
|
-
case END_EV:
|
|
134
|
-
case CANCEL_EV: that._end(e); break;
|
|
135
|
-
case RESIZE_EV: that._resize(); break;
|
|
136
|
-
case 'mouseout': that._mouseout(e); break;
|
|
137
|
-
case 'webkitTransitionEnd': that._transitionEnd(e); break;
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
_resize: function () {
|
|
142
|
-
this.refresh();
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
_pos: function (x, y) {
|
|
146
|
-
x = this.hScroll ? x : 0;
|
|
147
|
-
y = this.vScroll ? y : 0;
|
|
148
|
-
|
|
149
|
-
if (this.options.useTransform) {
|
|
150
|
-
this.scroller.style[vendor + 'Transform'] = trnOpen + x + 'px,' + y + 'px' + trnClose + ' scale(' + this.scale + ')';
|
|
151
|
-
} else {
|
|
152
|
-
x = mround(x);
|
|
153
|
-
y = mround(y);
|
|
154
|
-
this.scroller.style.left = x + 'px';
|
|
155
|
-
this.scroller.style.top = y + 'px';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.x = x;
|
|
159
|
-
this.y = y;
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
_start: function (e) {
|
|
163
|
-
var that = this,
|
|
164
|
-
point = hasTouch ? e.touches[0] : e,
|
|
165
|
-
matrix, x, y;
|
|
166
|
-
|
|
167
|
-
if (!that.enabled) return;
|
|
168
|
-
|
|
169
|
-
if (that.options.onBeforeScrollStart) that.options.onBeforeScrollStart.call(that, e);
|
|
170
|
-
|
|
171
|
-
if (that.options.useTransition) that._transitionTime(0);
|
|
172
|
-
|
|
173
|
-
that.moved = false;
|
|
174
|
-
that.animating = false;
|
|
175
|
-
that.zoomed = false;
|
|
176
|
-
that.distX = 0;
|
|
177
|
-
that.distY = 0;
|
|
178
|
-
that.absDistX = 0;
|
|
179
|
-
that.absDistY = 0;
|
|
180
|
-
that.dirX = 0;
|
|
181
|
-
that.dirY = 0;
|
|
182
|
-
|
|
183
|
-
if (that.options.momentum) {
|
|
184
|
-
if (that.options.useTransform) {
|
|
185
|
-
// Very lame general purpose alternative to CSSMatrix
|
|
186
|
-
matrix = getComputedStyle(that.scroller, null)[vendor + 'Transform'].replace(/[^0-9-.,]/g, '').split(',');
|
|
187
|
-
x = matrix[4] * 1;
|
|
188
|
-
y = matrix[5] * 1;
|
|
189
|
-
} else {
|
|
190
|
-
x = getComputedStyle(that.scroller, null).left.replace(/[^0-9-]/g, '') * 1;
|
|
191
|
-
y = getComputedStyle(that.scroller, null).top.replace(/[^0-9-]/g, '') * 1;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (x != that.x || y != that.y) {
|
|
195
|
-
if (that.options.useTransition) that._unbind('webkitTransitionEnd');
|
|
196
|
-
else cancelFrame(that.aniTime);
|
|
197
|
-
that.steps = [];
|
|
198
|
-
that._pos(x, y);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
that.startX = that.x;
|
|
203
|
-
that.startY = that.y;
|
|
204
|
-
that.pointX = point.pageX;
|
|
205
|
-
that.pointY = point.pageY;
|
|
206
|
-
|
|
207
|
-
that.startTime = e.timeStamp || Date.now();
|
|
208
|
-
|
|
209
|
-
if (that.options.onScrollStart) that.options.onScrollStart.call(that, e);
|
|
210
|
-
|
|
211
|
-
that._bind(MOVE_EV);
|
|
212
|
-
that._bind(END_EV);
|
|
213
|
-
that._bind(CANCEL_EV);
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
_move: function (e) {
|
|
217
|
-
var that = this,
|
|
218
|
-
point = hasTouch ? e.touches[0] : e,
|
|
219
|
-
deltaX = point.pageX - that.pointX,
|
|
220
|
-
deltaY = point.pageY - that.pointY,
|
|
221
|
-
newX = that.x + deltaX,
|
|
222
|
-
newY = that.y + deltaY,
|
|
223
|
-
timestamp = e.timeStamp || Date.now();
|
|
224
|
-
|
|
225
|
-
if (that.options.onBeforeScrollMove) that.options.onBeforeScrollMove.call(that, e);
|
|
226
|
-
|
|
227
|
-
that.pointX = point.pageX;
|
|
228
|
-
that.pointY = point.pageY;
|
|
229
|
-
|
|
230
|
-
// Slow down if outside of the boundaries
|
|
231
|
-
if (newX > 0 || newX < that.maxScrollX) {
|
|
232
|
-
newX = that.options.bounce ? that.x + (deltaX / 2) : newX >= 0 || that.maxScrollX >= 0 ? 0 : that.maxScrollX;
|
|
233
|
-
}
|
|
234
|
-
if (newY > 0 || newY < that.maxScrollY) {
|
|
235
|
-
newY = that.options.bounce ? that.y + (deltaY / 2) : newY >= 0 || that.maxScrollY >= 0 ? 0 : that.maxScrollY;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
that.distX += deltaX;
|
|
239
|
-
that.distY += deltaY;
|
|
240
|
-
that.absDistX = m.abs(that.distX);
|
|
241
|
-
that.absDistY = m.abs(that.distY);
|
|
242
|
-
|
|
243
|
-
if (that.absDistX < 6 && that.absDistY < 6) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Lock direction
|
|
248
|
-
if (that.options.lockDirection) {
|
|
249
|
-
if (that.absDistX > that.absDistY + 5) {
|
|
250
|
-
newY = that.y;
|
|
251
|
-
deltaY = 0;
|
|
252
|
-
} else if (that.absDistY > that.absDistX + 5) {
|
|
253
|
-
newX = that.x;
|
|
254
|
-
deltaX = 0;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
that.moved = true;
|
|
259
|
-
that._pos(newX, newY);
|
|
260
|
-
that.dirX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
|
|
261
|
-
that.dirY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
|
|
262
|
-
|
|
263
|
-
if (timestamp - that.startTime > 300) {
|
|
264
|
-
that.startTime = timestamp;
|
|
265
|
-
that.startX = that.x;
|
|
266
|
-
that.startY = that.y;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (that.options.onScrollMove) that.options.onScrollMove.call(that, e);
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
_end: function (e) {
|
|
273
|
-
// MODIFIED BY SAP:
|
|
274
|
-
// iScroll still stays in scrolling mode as long as there are other touches. This is fine when those touches are inside the scrollable area,
|
|
275
|
-
// as those touches just continue the scrolling process. But when the scrolled area is pulled down (or up) and the remaining touch is outside the scrolled area
|
|
276
|
-
// (=touching the background behind the page), and then this touch is also removed, then the page will not snap back.
|
|
277
|
-
// By commenting out the following line only the initial touch is considered for scrolling and this problem does not happen anymore. A side effect is that the user
|
|
278
|
-
// cannot pull down the page with one finger and then continue doing so with another finger. But actually this behavior is the same on iPhone, so this
|
|
279
|
-
// modification actually makes the behavior more native-like.
|
|
280
|
-
//
|
|
281
|
-
// if (hasTouch && e.touches.length != 0) return;
|
|
282
|
-
|
|
283
|
-
var that = this,
|
|
284
|
-
point = hasTouch ? e.changedTouches[0] : e,
|
|
285
|
-
target, ev,
|
|
286
|
-
momentumX = { dist:0, time:0 },
|
|
287
|
-
momentumY = { dist:0, time:0 },
|
|
288
|
-
duration = (e.timeStamp || Date.now()) - that.startTime,
|
|
289
|
-
newPosX = that.x,
|
|
290
|
-
newPosY = that.y,
|
|
291
|
-
newDuration;
|
|
292
|
-
|
|
293
|
-
that._unbind(MOVE_EV);
|
|
294
|
-
that._unbind(END_EV);
|
|
295
|
-
that._unbind(CANCEL_EV);
|
|
296
|
-
|
|
297
|
-
if (that.options.onBeforeScrollEnd) that.options.onBeforeScrollEnd.call(that, e);
|
|
298
|
-
|
|
299
|
-
if (!that.moved) {
|
|
300
|
-
if (hasTouch) {
|
|
301
|
-
// Find the last touched element
|
|
302
|
-
target = point.target;
|
|
303
|
-
while (target.nodeType != 1) target = target.parentNode;
|
|
304
|
-
|
|
305
|
-
if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
|
|
306
|
-
ev = document.createEvent('MouseEvents');
|
|
307
|
-
ev.initMouseEvent('click', true, true, e.view, 1,
|
|
308
|
-
point.screenX, point.screenY, point.clientX, point.clientY,
|
|
309
|
-
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
|
|
310
|
-
0, null);
|
|
311
|
-
ev._fake = true;
|
|
312
|
-
target.dispatchEvent(ev);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
that._resetPos(200);
|
|
317
|
-
|
|
318
|
-
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (duration < 300 && that.options.momentum) {
|
|
323
|
-
momentumX = newPosX ? that._momentum(newPosX - that.startX, duration, -that.x, that.scrollerW - that.wrapperW + that.x, that.options.bounce ? that.wrapperW : 0) : momentumX;
|
|
324
|
-
momentumY = newPosY ? that._momentum(newPosY - that.startY, duration, -that.y, (that.maxScrollY < 0 ? that.scrollerH - that.wrapperH + that.y : 0), that.options.bounce ? that.wrapperH : 0) : momentumY;
|
|
325
|
-
|
|
326
|
-
newPosX = that.x + momentumX.dist;
|
|
327
|
-
newPosY = that.y + momentumY.dist;
|
|
328
|
-
|
|
329
|
-
if ((that.x > 0 && newPosX > 0) || (that.x < that.maxScrollX && newPosX < that.maxScrollX)) momentumX = { dist:0, time:0 };
|
|
330
|
-
if ((that.y > 0 && newPosY > 0) || (that.y < that.maxScrollY && newPosY < that.maxScrollY)) momentumY = { dist:0, time:0 };
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (momentumX.dist || momentumY.dist) {
|
|
334
|
-
newDuration = m.max(m.max(momentumX.time, momentumY.time), 10);
|
|
335
|
-
|
|
336
|
-
that.scrollTo(mround(newPosX), mround(newPosY), newDuration);
|
|
337
|
-
|
|
338
|
-
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
that._resetPos(200);
|
|
343
|
-
if (that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
_resetPos: function (time) {
|
|
347
|
-
var that = this,
|
|
348
|
-
resetX = that.x >= 0 ? 0 : that.x < that.maxScrollX ? that.maxScrollX : that.x,
|
|
349
|
-
resetY = that.y >= 0 || that.maxScrollY > 0 ? 0 : that.y < that.maxScrollY ? that.maxScrollY : that.y;
|
|
350
|
-
|
|
351
|
-
if (resetX == that.x && resetY == that.y) {
|
|
352
|
-
if (that.moved) {
|
|
353
|
-
if (that.options.onScrollEnd) that.options.onScrollEnd.call(that); // Execute custom code on scroll end
|
|
354
|
-
that.moved = false;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
that.scrollTo(resetX, resetY, time || 0);
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
_mouseout: function (e) {
|
|
364
|
-
var t = e.relatedTarget;
|
|
365
|
-
|
|
366
|
-
if (!t) {
|
|
367
|
-
this._end(e);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
while (t = t.parentNode) if (t == this.wrapper) return;
|
|
372
|
-
|
|
373
|
-
this._end(e);
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
_transitionEnd: function (e) {
|
|
377
|
-
var that = this;
|
|
378
|
-
|
|
379
|
-
if (e.target != that.scroller) return;
|
|
380
|
-
|
|
381
|
-
that._unbind('webkitTransitionEnd');
|
|
382
|
-
|
|
383
|
-
that._startAni();
|
|
384
|
-
},
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
*
|
|
388
|
-
* Utilities
|
|
389
|
-
*
|
|
390
|
-
*/
|
|
391
|
-
_startAni: function () {
|
|
392
|
-
var that = this,
|
|
393
|
-
startX = that.x, startY = that.y,
|
|
394
|
-
startTime = Date.now(),
|
|
395
|
-
step, easeOut,
|
|
396
|
-
animate;
|
|
397
|
-
|
|
398
|
-
if (that.animating) return;
|
|
399
|
-
|
|
400
|
-
if (!that.steps.length) {
|
|
401
|
-
that._resetPos(400);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
step = that.steps.shift();
|
|
406
|
-
|
|
407
|
-
if (step.x == startX && step.y == startY) step.time = 0;
|
|
408
|
-
|
|
409
|
-
that.animating = true;
|
|
410
|
-
that.moved = true;
|
|
411
|
-
|
|
412
|
-
if (that.options.useTransition) {
|
|
413
|
-
that._transitionTime(step.time);
|
|
414
|
-
that._pos(step.x, step.y);
|
|
415
|
-
that.animating = false;
|
|
416
|
-
if (step.time) that._bind('webkitTransitionEnd');
|
|
417
|
-
else that._resetPos(0);
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
animate = function () {
|
|
422
|
-
var now = Date.now(),
|
|
423
|
-
newX, newY;
|
|
424
|
-
|
|
425
|
-
if (now >= startTime + step.time) {
|
|
426
|
-
that._pos(step.x, step.y);
|
|
427
|
-
that.animating = false;
|
|
428
|
-
if (that.options.onAnimationEnd) that.options.onAnimationEnd.call(that); // Execute custom code on animation end
|
|
429
|
-
that._startAni();
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
now = (now - startTime) / step.time - 1;
|
|
434
|
-
easeOut = m.sqrt(1 - now * now);
|
|
435
|
-
newX = (step.x - startX) * easeOut + startX;
|
|
436
|
-
newY = (step.y - startY) * easeOut + startY;
|
|
437
|
-
that._pos(newX, newY);
|
|
438
|
-
if (that.animating) that.aniTime = nextFrame(animate);
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
animate();
|
|
442
|
-
},
|
|
443
|
-
|
|
444
|
-
_transitionTime: function (time) {
|
|
445
|
-
this.scroller.style[vendor + 'TransitionDuration'] = time + 'ms';
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
_momentum: function (dist, time, maxDistUpper, maxDistLower, size) {
|
|
449
|
-
var deceleration = 0.0006,
|
|
450
|
-
speed = m.abs(dist) / time,
|
|
451
|
-
newDist = (speed * speed) / (2 * deceleration),
|
|
452
|
-
newTime = 0, outsideDist = 0;
|
|
453
|
-
|
|
454
|
-
// Proportinally reduce speed if we are outside of the boundaries
|
|
455
|
-
if (dist > 0 && newDist > maxDistUpper) {
|
|
456
|
-
outsideDist = size / (6 / (newDist / speed * deceleration));
|
|
457
|
-
maxDistUpper = maxDistUpper + outsideDist;
|
|
458
|
-
speed = speed * maxDistUpper / newDist;
|
|
459
|
-
newDist = maxDistUpper;
|
|
460
|
-
} else if (dist < 0 && newDist > maxDistLower) {
|
|
461
|
-
outsideDist = size / (6 / (newDist / speed * deceleration));
|
|
462
|
-
maxDistLower = maxDistLower + outsideDist;
|
|
463
|
-
speed = speed * maxDistLower / newDist;
|
|
464
|
-
newDist = maxDistLower;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
newDist = newDist * (dist < 0 ? -1 : 1);
|
|
468
|
-
newTime = speed / deceleration;
|
|
469
|
-
|
|
470
|
-
return { dist: newDist, time: mround(newTime) };
|
|
471
|
-
},
|
|
472
|
-
|
|
473
|
-
_offset: function (el) {
|
|
474
|
-
var left = -el.offsetLeft,
|
|
475
|
-
top = -el.offsetTop;
|
|
476
|
-
|
|
477
|
-
while (el = el.offsetParent) {
|
|
478
|
-
left -= el.offsetLeft;
|
|
479
|
-
top -= el.offsetTop;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return { left: left, top: top };
|
|
483
|
-
},
|
|
484
|
-
|
|
485
|
-
_bind: function (type, el, bubble) {
|
|
486
|
-
(el || this.scroller).addEventListener(type, this, !!bubble);
|
|
487
|
-
},
|
|
488
|
-
|
|
489
|
-
_unbind: function (type, el, bubble) {
|
|
490
|
-
(el || this.scroller).removeEventListener(type, this, !!bubble);
|
|
491
|
-
},
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
*
|
|
496
|
-
* Public methods
|
|
497
|
-
*
|
|
498
|
-
*/
|
|
499
|
-
destroy: function () {
|
|
500
|
-
var that = this;
|
|
501
|
-
|
|
502
|
-
that.scroller.style[vendor + 'Transform'] = '';
|
|
503
|
-
|
|
504
|
-
// Remove the event listeners
|
|
505
|
-
that._unbind(RESIZE_EV, window);
|
|
506
|
-
that._unbind(START_EV);
|
|
507
|
-
that._unbind(MOVE_EV);
|
|
508
|
-
that._unbind(END_EV);
|
|
509
|
-
that._unbind(CANCEL_EV);
|
|
510
|
-
that._unbind('mouseout', that.wrapper);
|
|
511
|
-
if (that.options.useTransition) that._unbind('webkitTransitionEnd');
|
|
512
|
-
|
|
513
|
-
if (that.options.onDestroy) that.options.onDestroy.call(that);
|
|
514
|
-
},
|
|
515
|
-
|
|
516
|
-
refresh: function () {
|
|
517
|
-
var that = this,
|
|
518
|
-
offset;
|
|
519
|
-
|
|
520
|
-
that.wrapperW = that.wrapper.clientWidth;
|
|
521
|
-
that.wrapperH = that.wrapper.clientHeight;
|
|
522
|
-
|
|
523
|
-
that.scrollerW = that.scroller.offsetWidth;
|
|
524
|
-
that.scrollerH = that.scroller.offsetHeight;
|
|
525
|
-
that.maxScrollX = that.wrapperW - that.scrollerW;
|
|
526
|
-
that.maxScrollY = that.wrapperH - that.scrollerH;
|
|
527
|
-
that.dirX = 0;
|
|
528
|
-
that.dirY = 0;
|
|
529
|
-
|
|
530
|
-
that.hScroll = that.options.hScroll && that.maxScrollX < 0;
|
|
531
|
-
that.vScroll = that.options.vScroll && (!that.options.bounceLock && !that.hScroll || that.scrollerH > that.wrapperH);
|
|
532
|
-
|
|
533
|
-
offset = that._offset(that.wrapper);
|
|
534
|
-
that.wrapperOffsetLeft = -offset.left;
|
|
535
|
-
that.wrapperOffsetTop = -offset.top;
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
that.scroller.style[vendor + 'TransitionDuration'] = '0';
|
|
539
|
-
|
|
540
|
-
that._resetPos(200);
|
|
541
|
-
},
|
|
542
|
-
|
|
543
|
-
scrollTo: function (x, y, time, relative) {
|
|
544
|
-
var that = this,
|
|
545
|
-
step = x,
|
|
546
|
-
i, l;
|
|
547
|
-
|
|
548
|
-
that.stop();
|
|
549
|
-
|
|
550
|
-
if (!step.length) step = [{ x: x, y: y, time: time, relative: relative }];
|
|
551
|
-
|
|
552
|
-
for (i=0, l=step.length; i<l; i++) {
|
|
553
|
-
if (step[i].relative) { step[i].x = that.x - step[i].x; step[i].y = that.y - step[i].y; }
|
|
554
|
-
that.steps.push({ x: step[i].x, y: step[i].y, time: step[i].time || 0 });
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
that._startAni();
|
|
558
|
-
},
|
|
559
|
-
|
|
560
|
-
scrollToElement: function (el, time) {
|
|
561
|
-
var that = this, pos;
|
|
562
|
-
el = el.nodeType ? el : that.scroller.querySelector(el);
|
|
563
|
-
if (!el) return;
|
|
564
|
-
|
|
565
|
-
pos = that._offset(el);
|
|
566
|
-
pos.left += that.wrapperOffsetLeft;
|
|
567
|
-
pos.top += that.wrapperOffsetTop;
|
|
568
|
-
|
|
569
|
-
pos.left = pos.left > 0 ? 0 : pos.left < that.maxScrollX ? that.maxScrollX : pos.left;
|
|
570
|
-
pos.top = pos.top > 0 ? 0 : pos.top < that.maxScrollY ? that.maxScrollY : pos.top;
|
|
571
|
-
time = time === undefined ? m.max(m.abs(pos.left)*2, m.abs(pos.top)*2) : time;
|
|
572
|
-
|
|
573
|
-
that.scrollTo(pos.left, pos.top, time);
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
disable: function () {
|
|
577
|
-
this.stop();
|
|
578
|
-
this._resetPos(0);
|
|
579
|
-
this.enabled = false;
|
|
580
|
-
|
|
581
|
-
// If disabled after touchstart we make sure that there are no left over events
|
|
582
|
-
this._unbind(MOVE_EV);
|
|
583
|
-
this._unbind(END_EV);
|
|
584
|
-
this._unbind(CANCEL_EV);
|
|
585
|
-
},
|
|
586
|
-
|
|
587
|
-
enable: function () {
|
|
588
|
-
this.enabled = true;
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
stop: function () {
|
|
592
|
-
cancelFrame(this.aniTime);
|
|
593
|
-
this.steps = [];
|
|
594
|
-
this.moved = false;
|
|
595
|
-
this.animating = false;
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
if (typeof exports !== 'undefined') exports.iScroll = iScroll;
|
|
601
|
-
else window.iScroll = iScroll;
|
|
602
|
-
|
|
603
|
-
})();
|