diff --git a/ionic/components.js b/ionic/components.js index 7a9d7f4aad..1ed6bf3ba6 100644 --- a/ionic/components.js +++ b/ionic/components.js @@ -19,6 +19,7 @@ export * from 'ionic/components/nav/nav-push' export * from 'ionic/components/nav-bar/nav-bar' export * from 'ionic/components/slides/slides' export * from 'ionic/components/radio/radio' +export * from 'ionic/components/scroll/scroll' export * from 'ionic/components/scroll/pull-to-refresh' export * from 'ionic/components/search-bar/search-bar' // export * from 'ionic/components/split-view/split-view' diff --git a/ionic/components/app/structure.scss b/ionic/components/app/structure.scss index f96c40a5f8..7594a8a8c7 100644 --- a/ionic/components/app/structure.scss +++ b/ionic/components/app/structure.scss @@ -121,21 +121,3 @@ ion-toolbar { min-height: 4.4rem; background: white; } - -ion-content { - position: relative; - display: block; - flex: 1; -} - -.scroll-content { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - overflow-y: auto; - overflow-x: hidden; - -webkit-overflow-scrolling: touch; - will-change: scroll-position; -} diff --git a/ionic/components/content/content.js b/ionic/components/content/content.js index a931333f74..ef6f8aeacb 100644 --- a/ionic/components/content/content.js +++ b/ionic/components/content/content.js @@ -11,7 +11,7 @@ import {Ion} from '../ion'; @View({ template: `
` }) -export class Content extends Ion{ +export class Content extends Ion { constructor(elementRef: ElementRef) { super(elementRef); diff --git a/ionic/components/content/content.scss b/ionic/components/content/content.scss index 9290195d97..817bb02b83 100644 --- a/ionic/components/content/content.scss +++ b/ionic/components/content/content.scss @@ -11,5 +11,21 @@ $content-background-color: #fff !default; } ion-content { + position: relative; + display: block; + flex: 1; background-color: $content-background-color; + + .scroll-content { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + overflow-y: auto; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + will-change: scroll-position; + } + } diff --git a/ionic/components/scroll/scroll.js b/ionic/components/scroll/scroll.js new file mode 100644 index 0000000000..c6896b4287 --- /dev/null +++ b/ionic/components/scroll/scroll.js @@ -0,0 +1,43 @@ +import {ElementRef} from 'angular2/angular2' +import {Component} from 'angular2/src/core/annotations_impl/annotations'; +import {View} from 'angular2/src/core/annotations_impl/view'; + +import {Ion} from '../ion'; + + +/** + * ion-scroll is a non-flexboxed scroll area that can + * scroll horizontally or vertically. + */ +@Component({ + selector: 'ion-scroll', + properties: [ + 'scrollX', 'scrollY' + ], + host: { + '[class.scroll-x]': 'scrollX', + '[class.scroll-y]': 'scrollY' + } +}) +@View({ + template: `
` +}) +export class Scroll extends Ion { + constructor(elementRef: ElementRef) { + super(elementRef); + + setTimeout(() => { + this.scrollElement = elementRef.nativeElement.children[0]; + }); + } + + addScrollEventListener(handler) { + if(!this.scrollElement) { return; } + + this.scrollElement.addEventListener('scroll', handler); + + return () => { + this.scrollElement.removeEventListener('scroll', handler); + } + } +} diff --git a/ionic/components/scroll/scroll.scss b/ionic/components/scroll/scroll.scss new file mode 100644 index 0000000000..527d97d5c7 --- /dev/null +++ b/ionic/components/scroll/scroll.scss @@ -0,0 +1,25 @@ +ion-scroll { + position: relative; + display: block; + background-color: $content-background-color; + &.scroll-x .scroll-content { + overflow-x: auto; + } + &.scroll-y .scroll-content { + overflow-y: auto; + } + + .scroll-content { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + overflow-y: hidden; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + will-change: scroll-position; + + } + +} diff --git a/ionic/components/scroll/test/basic/eight_horns.png b/ionic/components/scroll/test/basic/eight_horns.png new file mode 100644 index 0000000000..103fa9cce7 Binary files /dev/null and b/ionic/components/scroll/test/basic/eight_horns.png differ diff --git a/ionic/components/scroll/test/basic/index.js b/ionic/components/scroll/test/basic/index.js new file mode 100644 index 0000000000..265d76f100 --- /dev/null +++ b/ionic/components/scroll/test/basic/index.js @@ -0,0 +1,21 @@ +import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; + +import {IonicView} from 'ionic/ionic'; + + +@Component({ selector: 'ion-app' }) +@IonicView({ + templateUrl: 'main.html' +}) +class IonicApp { + constructor() { + console.log('IonicApp Start') + } + doRefresh() { + console.log('DOREFRESH') + } +} + +export function main(ionicBootstrap) { + ionicBootstrap(IonicApp); +} diff --git a/ionic/components/scroll/test/basic/main.html b/ionic/components/scroll/test/basic/main.html new file mode 100644 index 0000000000..167abf62bd --- /dev/null +++ b/ionic/components/scroll/test/basic/main.html @@ -0,0 +1,37 @@ + + + Scroll + + + + +

Horizontal

+ +
+
+ +

Vertical

+ +
+
+ +

Both

+ +
+
+ +
+ +
+ diff --git a/ionic/config/annotations.js b/ionic/config/annotations.js index 380e6bbfda..b4a930b8ef 100644 --- a/ionic/config/annotations.js +++ b/ionic/config/annotations.js @@ -4,7 +4,7 @@ import {View} from 'angular2/src/core/annotations_impl/view'; import * as util from 'ionic/util'; import {IonicConfig} from './config'; import { - Aside, Content, Refresher, + Aside, Content, Scroll, Refresher, Slides, Slide, SlidePager, Tabs, Tab, List, Item, @@ -24,7 +24,7 @@ export class IonicView extends View { coreDirectives, // Content - Aside, Content, Refresher, + Aside, Content, Scroll, Refresher, List, Item, Slides, Slide, SlidePager, Tabs, Tab, diff --git a/ionic/ionic.scss b/ionic/ionic.scss index 1284de8f2c..62be7c5db9 100644 --- a/ionic/ionic.scss +++ b/ionic/ionic.scss @@ -41,6 +41,7 @@ "components/nav-bar/nav-bar", "components/slides/slides", "components/radio/radio", + "components/scroll/scroll", "components/scroll/pull-to-refresh", "components/search-bar/search-bar", "components/segment/segment",