{"action":"created","comment":{"url":"https://api.github.com/repos/driftyco/ionic/pulls/comments/65243351","id":65243351,"diff_hunk":"@@ -47,19 +81,154 @@ import {List} from '../list/list';\n  * @see {@link ../Item Item API Docs}\n  * @see {@link ../../list/List List API Docs}\n  */\n+ // host: {\n+ //   '[hidden]': '_hidden',\n+ //   'class': 'toolbar',\n+ //   '[class.statusbar-padding]': '_sbPadding'\n+ // },\n @Component({\n   selector: 'ion-item-sliding',\n   template:\n     '<ng-content select=\"ion-item,[ion-item]\"></ng-content>' +\n     '<ng-content select=\"ion-item-options\"></ng-content>',\n   changeDetection: ChangeDetectionStrategy.OnPush,\n-  encapsulation: ViewEncapsulation.None,\n+  encapsulation: ViewEncapsulation.None\n })\n export class ItemSliding {\n+  private _openAmount: number = 0;\n+  private _startX: number = 0;\n+  private _offsetX: number = 0;\n+  private _optsWidthRightSide: number = 0;\n+  private _optsWidthLeftSide: number = 0;\n+  private _sides: SideFlags;\n+  private _timer: number = null;\n+  private _leftOptions: ItemOptions;\n+  private _rightOptions: ItemOptions;\n+  private _optsDirty: boolean = true;\n+\n+  @ContentChild(Item) item;\n \n-  constructor(@Optional() private _list: List, elementRef: ElementRef) {\n+  constructor( @Optional() private _list: List, private _renderer: Renderer, private _elementRef: ElementRef) {\n     _list.enableSlidingItems(true);\n-    elementRef.nativeElement.$ionSlide = ++slideIds;\n+    _elementRef.nativeElement.$ionComponent = this;\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  @ContentChildren(ItemOptions)\n+  set _itemOptions(itemOptions) {\n+    var sides = 0;\n+    for (var item of itemOptions.toArray()) {\n+      var side = item.getSides();\n+      switch(side) {\n+        case SideFlags.Left: this._leftOptions = item; break;\n+        case SideFlags.Right: this._rightOptions = item; break;\n+      }\n+      sides |= item.getSides();\n+    }\n+    this._optsDirty = true;\n+    this._sides = sides;\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  _startSliding(startX: number) {\n+    this._addClass('active-slide');\n+    this._offsetX = this._openAmount;\n+    this._startX = startX;\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  _moveSliding(x: number): number {\n+    if(this._optsDirty) {\n+      if(this._optsWidthRightSide == 0 && this._rightOptions) {\n+        this._optsWidthRightSide = this._rightOptions.getWidth();\n+      }\n+      if(this._leftOptions) {\n+        this._optsWidthLeftSide = this._leftOptions.getWidth();\n+      }\n+      this._optsDirty = false;\n+    }\n+\n+    this._openAmount = computeOpenAmount(\n+      x,\n+      this._startX,\n+      this._offsetX,\n+      this._optsWidthRightSide,\n+      this._optsWidthLeftSide,\n+      this._sides\n+    );\n+    this._updateVisual(false);\n+    return this._openAmount;\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  _endSliding(velocity: number): number {\n+    this._openAmount = computeRestingPoint(\n+      this._openAmount,\n+      this._optsWidthRightSide,\n+      this._optsWidthLeftSide,\n+      velocity\n+    );\n+    this._updateVisual(true);\n+    return this._openAmount;\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  private _updateVisual(isFinal: boolean) {\n+    if(this._timer) {\n+      clearTimeout(this._timer);\n+      this._timer = null;\n+    }\n+    let openAmount = this._openAmount;\n+    let didEnd = openAmount == 0;\n+    if(didEnd) {\n+        // TODO: refactor. there must exist a better way\n+        // if sliding ended, we wait 400ms until animation finishes\n+        this._timer = setTimeout(()=> {\n+          this._removeClass('active-slide');\n+          this._removeClass('active-options-right');\n+          this._removeClass('active-options-left');\n+          this._timer = null;\n+        }, 400);\n+\n+    }else if(openAmount > 0) {\n+        this._addClass('active-options-right');\n+    }else if(openAmount < 0) {\n+        this._addClass('active-options-left');\n+    }\n+\n+    this.item.setCssStyle(CSS.transition, (isFinal ? '' : 'none'));\n+    this.item.setCssStyle(CSS.transform, (didEnd ? '' : 'translate3d(' + -openAmount + 'px,0,0)'));\n+  }\n+\n+  /**\n+   * @private\n+   */\n+  private _addClass(className: string) {","path":"src/components/item/item-sliding.ts","position":183,"original_position":183,"commit_id":"9e22754c2c867629b3f1f8cfc6ab45783f6623c7","original_commit_id":"04ea18e7be93b171ca81d96518e35a5dd194374c","user":{"login":"adamdbradley","id":452425,"avatar_url":"https://avatars.githubusercontent.com/u/452425?v=3","gravatar_id":"","url":"https://api.github.com/users/adamdbradley","html_url":"https://github.com/adamdbradley","followers_url":"https://api.github.com/users/adamdbradley/followers","following_url":"https://api.github.com/users/adamdbradley/following{/other_user}","gists_url":"https://api.github.com/users/adamdbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/adamdbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamdbradley/subscriptions","organizations_url":"https://api.github.com/users/adamdbradley/orgs","repos_url":"https://api.github.com/users/adamdbradley/repos","events_url":"https://api.github.com/users/adamdbradley/events{/privacy}","received_events_url":"https://api.github.com/users/adamdbradley/received_events","type":"User","site_admin":false},"body":"_addClass and _removeClass could be combined like how the renderer's `setElementClass` works, where the 3rd arg is a boolean. Instead you could just have `_setClass`","created_at":"2016-05-31T19:02:03Z","updated_at":"2016-05-31T19:02:03Z","html_url":"https://github.com/driftyco/ionic/pull/6686#discussion_r65243351","pull_request_url":"https://api.github.com/repos/driftyco/ionic/pulls/6686","_links":{"self":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/comments/65243351"},"html":{"href":"https://github.com/driftyco/ionic/pull/6686#discussion_r65243351"},"pull_request":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/6686"}}},"pull_request":{"url":"https://api.github.com/repos/driftyco/ionic/pulls/6686","id":71798568,"html_url":"https://github.com/driftyco/ionic/pull/6686","diff_url":"https://github.com/driftyco/ionic/pull/6686.diff","patch_url":"https://github.com/driftyco/ionic/pull/6686.patch","issue_url":"https://api.github.com/repos/driftyco/ionic/issues/6686","number":6686,"state":"open","locked":false,"title":"feat(item): two-way sliding of items","user":{"login":"manucorporat","id":127379,"avatar_url":"https://avatars.githubusercontent.com/u/127379?v=3","gravatar_id":"","url":"https://api.github.com/users/manucorporat","html_url":"https://github.com/manucorporat","followers_url":"https://api.github.com/users/manucorporat/followers","following_url":"https://api.github.com/users/manucorporat/following{/other_user}","gists_url":"https://api.github.com/users/manucorporat/gists{/gist_id}","starred_url":"https://api.github.com/users/manucorporat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manucorporat/subscriptions","organizations_url":"https://api.github.com/users/manucorporat/orgs","repos_url":"https://api.github.com/users/manucorporat/repos","events_url":"https://api.github.com/users/manucorporat/events{/privacy}","received_events_url":"https://api.github.com/users/manucorporat/received_events","type":"User","site_admin":false},"body":"#### Short description of what this resolves:\r\nImplements: feature(ion-item-sliding): Allow item also to swipe from left to right #5073\r\n\r\nit should be 100% back compatible.\r\n\r\n#### Changes proposed in this pull request:\r\n\r\n- adds an optional `side` attribute to `ion-item-options`\r\n- I aggressively refactored the sliding code to try to make it more readable and simple.\r\n- moved logic to external functions so they can be unit tested easily\r\n\r\nThis may cause new issues. I haven't tested the code for side effects, so please don't merge just yet.\r\nFeel free to pull it locally and try it.\r\n\r\n![buenooo](https://cloud.githubusercontent.com/assets/127379/15626793/c7a2a11e-24ce-11e6-96de-31a378ecf8f4.gif)\r\n\r\nExample code:\r\n```html\r\n    <ion-item-sliding #item>\r\n      <ion-item>Two-way sliding</ion-item>\r\n\r\n      <!-- Same: <ion-item-options> -->\r\n      <ion-item-options side=\"right\">\r\n        <button primary (click)=\"archive(item)\">Archive</button>\r\n        <button danger (click)=\"del(item)\">Delete</button>\r\n      </ion-item-options>\r\n\r\n      <ion-item-options side=\"left\">\r\n        <button secondary (click)=\"unread(item)\">Unread</button>\r\n      </ion-item-options>\r\n    </ion-item-sliding>\r\n```\r\n\r\n\r\n**Ionic Version**: 2.x\r\n\r\n**Fixes**: #5073\r\n","created_at":"2016-05-28T10:21:39Z","updated_at":"2016-05-31T19:02:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d02698a964395714be319939c410ba888fb19023","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/driftyco/ionic/pulls/6686/commits","review_comments_url":"https://api.github.com/repos/driftyco/ionic/pulls/6686/comments","review_comment_url":"https://api.github.com/repos/driftyco/ionic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/driftyco/ionic/issues/6686/comments","statuses_url":"https://api.github.com/repos/driftyco/ionic/statuses/9e22754c2c867629b3f1f8cfc6ab45783f6623c7","head":{"label":"manucorporat:sliding-two-way","ref":"sliding-two-way","sha":"9e22754c2c867629b3f1f8cfc6ab45783f6623c7","user":{"login":"manucorporat","id":127379,"avatar_url":"https://avatars.githubusercontent.com/u/127379?v=3","gravatar_id":"","url":"https://api.github.com/users/manucorporat","html_url":"https://github.com/manucorporat","followers_url":"https://api.github.com/users/manucorporat/followers","following_url":"https://api.github.com/users/manucorporat/following{/other_user}","gists_url":"https://api.github.com/users/manucorporat/gists{/gist_id}","starred_url":"https://api.github.com/users/manucorporat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manucorporat/subscriptions","organizations_url":"https://api.github.com/users/manucorporat/orgs","repos_url":"https://api.github.com/users/manucorporat/repos","events_url":"https://api.github.com/users/manucorporat/events{/privacy}","received_events_url":"https://api.github.com/users/manucorporat/received_events","type":"User","site_admin":false},"repo":{"id":49879738,"name":"ionic","full_name":"manucorporat/ionic","owner":{"login":"manucorporat","id":127379,"avatar_url":"https://avatars.githubusercontent.com/u/127379?v=3","gravatar_id":"","url":"https://api.github.com/users/manucorporat","html_url":"https://github.com/manucorporat","followers_url":"https://api.github.com/users/manucorporat/followers","following_url":"https://api.github.com/users/manucorporat/following{/other_user}","gists_url":"https://api.github.com/users/manucorporat/gists{/gist_id}","starred_url":"https://api.github.com/users/manucorporat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manucorporat/subscriptions","organizations_url":"https://api.github.com/users/manucorporat/orgs","repos_url":"https://api.github.com/users/manucorporat/repos","events_url":"https://api.github.com/users/manucorporat/events{/privacy}","received_events_url":"https://api.github.com/users/manucorporat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/manucorporat/ionic","description":"Advanced HTML5 mobile development framework and SDK. Build incredible mobile apps with web technologies you already know and love. Best friends with AngularJS.","fork":true,"url":"https://api.github.com/repos/manucorporat/ionic","forks_url":"https://api.github.com/repos/manucorporat/ionic/forks","keys_url":"https://api.github.com/repos/manucorporat/ionic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/manucorporat/ionic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/manucorporat/ionic/teams","hooks_url":"https://api.github.com/repos/manucorporat/ionic/hooks","issue_events_url":"https://api.github.com/repos/manucorporat/ionic/issues/events{/number}","events_url":"https://api.github.com/repos/manucorporat/ionic/events","assignees_url":"https://api.github.com/repos/manucorporat/ionic/assignees{/user}","branches_url":"https://api.github.com/repos/manucorporat/ionic/branches{/branch}","tags_url":"https://api.github.com/repos/manucorporat/ionic/tags","blobs_url":"https://api.github.com/repos/manucorporat/ionic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/manucorporat/ionic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/manucorporat/ionic/git/refs{/sha}","trees_url":"https://api.github.com/repos/manucorporat/ionic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/manucorporat/ionic/statuses/{sha}","languages_url":"https://api.github.com/repos/manucorporat/ionic/languages","stargazers_url":"https://api.github.com/repos/manucorporat/ionic/stargazers","contributors_url":"https://api.github.com/repos/manucorporat/ionic/contributors","subscribers_url":"https://api.github.com/repos/manucorporat/ionic/subscribers","subscription_url":"https://api.github.com/repos/manucorporat/ionic/subscription","commits_url":"https://api.github.com/repos/manucorporat/ionic/commits{/sha}","git_commits_url":"https://api.github.com/repos/manucorporat/ionic/git/commits{/sha}","comments_url":"https://api.github.com/repos/manucorporat/ionic/comments{/number}","issue_comment_url":"https://api.github.com/repos/manucorporat/ionic/issues/comments{/number}","contents_url":"https://api.github.com/repos/manucorporat/ionic/contents/{+path}","compare_url":"https://api.github.com/repos/manucorporat/ionic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/manucorporat/ionic/merges","archive_url":"https://api.github.com/repos/manucorporat/ionic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/manucorporat/ionic/downloads","issues_url":"https://api.github.com/repos/manucorporat/ionic/issues{/number}","pulls_url":"https://api.github.com/repos/manucorporat/ionic/pulls{/number}","milestones_url":"https://api.github.com/repos/manucorporat/ionic/milestones{/number}","notifications_url":"https://api.github.com/repos/manucorporat/ionic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/manucorporat/ionic/labels{/name}","releases_url":"https://api.github.com/repos/manucorporat/ionic/releases{/id}","deployments_url":"https://api.github.com/repos/manucorporat/ionic/deployments","created_at":"2016-01-18T13:50:25Z","updated_at":"2016-01-18T13:50:29Z","pushed_at":"2016-05-31T18:53:15Z","git_url":"git://github.com/manucorporat/ionic.git","ssh_url":"git@github.com:manucorporat/ionic.git","clone_url":"https://github.com/manucorporat/ionic.git","svn_url":"https://github.com/manucorporat/ionic","homepage":"http://ionicframework.com/","size":62135,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"driftyco:2.0","ref":"2.0","sha":"6bd91f02a35444928f0928cfd1fb9dfb777492ef","user":{"login":"driftyco","id":3171503,"avatar_url":"https://avatars.githubusercontent.com/u/3171503?v=3","gravatar_id":"","url":"https://api.github.com/users/driftyco","html_url":"https://github.com/driftyco","followers_url":"https://api.github.com/users/driftyco/followers","following_url":"https://api.github.com/users/driftyco/following{/other_user}","gists_url":"https://api.github.com/users/driftyco/gists{/gist_id}","starred_url":"https://api.github.com/users/driftyco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driftyco/subscriptions","organizations_url":"https://api.github.com/users/driftyco/orgs","repos_url":"https://api.github.com/users/driftyco/repos","events_url":"https://api.github.com/users/driftyco/events{/privacy}","received_events_url":"https://api.github.com/users/driftyco/received_events","type":"Organization","site_admin":false},"repo":{"id":12256376,"name":"ionic","full_name":"driftyco/ionic","owner":{"login":"driftyco","id":3171503,"avatar_url":"https://avatars.githubusercontent.com/u/3171503?v=3","gravatar_id":"","url":"https://api.github.com/users/driftyco","html_url":"https://github.com/driftyco","followers_url":"https://api.github.com/users/driftyco/followers","following_url":"https://api.github.com/users/driftyco/following{/other_user}","gists_url":"https://api.github.com/users/driftyco/gists{/gist_id}","starred_url":"https://api.github.com/users/driftyco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/driftyco/subscriptions","organizations_url":"https://api.github.com/users/driftyco/orgs","repos_url":"https://api.github.com/users/driftyco/repos","events_url":"https://api.github.com/users/driftyco/events{/privacy}","received_events_url":"https://api.github.com/users/driftyco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/driftyco/ionic","description":"Advanced HTML5 mobile development framework and SDK. Build incredible mobile apps with web technologies you already know and love. Best friends with AngularJS.","fork":false,"url":"https://api.github.com/repos/driftyco/ionic","forks_url":"https://api.github.com/repos/driftyco/ionic/forks","keys_url":"https://api.github.com/repos/driftyco/ionic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/driftyco/ionic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/driftyco/ionic/teams","hooks_url":"https://api.github.com/repos/driftyco/ionic/hooks","issue_events_url":"https://api.github.com/repos/driftyco/ionic/issues/events{/number}","events_url":"https://api.github.com/repos/driftyco/ionic/events","assignees_url":"https://api.github.com/repos/driftyco/ionic/assignees{/user}","branches_url":"https://api.github.com/repos/driftyco/ionic/branches{/branch}","tags_url":"https://api.github.com/repos/driftyco/ionic/tags","blobs_url":"https://api.github.com/repos/driftyco/ionic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/driftyco/ionic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/driftyco/ionic/git/refs{/sha}","trees_url":"https://api.github.com/repos/driftyco/ionic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/driftyco/ionic/statuses/{sha}","languages_url":"https://api.github.com/repos/driftyco/ionic/languages","stargazers_url":"https://api.github.com/repos/driftyco/ionic/stargazers","contributors_url":"https://api.github.com/repos/driftyco/ionic/contributors","subscribers_url":"https://api.github.com/repos/driftyco/ionic/subscribers","subscription_url":"https://api.github.com/repos/driftyco/ionic/subscription","commits_url":"https://api.github.com/repos/driftyco/ionic/commits{/sha}","git_commits_url":"https://api.github.com/repos/driftyco/ionic/git/commits{/sha}","comments_url":"https://api.github.com/repos/driftyco/ionic/comments{/number}","issue_comment_url":"https://api.github.com/repos/driftyco/ionic/issues/comments{/number}","contents_url":"https://api.github.com/repos/driftyco/ionic/contents/{+path}","compare_url":"https://api.github.com/repos/driftyco/ionic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/driftyco/ionic/merges","archive_url":"https://api.github.com/repos/driftyco/ionic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/driftyco/ionic/downloads","issues_url":"https://api.github.com/repos/driftyco/ionic/issues{/number}","pulls_url":"https://api.github.com/repos/driftyco/ionic/pulls{/number}","milestones_url":"https://api.github.com/repos/driftyco/ionic/milestones{/number}","notifications_url":"https://api.github.com/repos/driftyco/ionic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/driftyco/ionic/labels{/name}","releases_url":"https://api.github.com/repos/driftyco/ionic/releases{/id}","deployments_url":"https://api.github.com/repos/driftyco/ionic/deployments","created_at":"2013-08-20T23:06:02Z","updated_at":"2016-05-31T17:36:30Z","pushed_at":"2016-05-31T18:53:15Z","git_url":"git://github.com/driftyco/ionic.git","ssh_url":"git@github.com:driftyco/ionic.git","clone_url":"https://github.com/driftyco/ionic.git","svn_url":"https://github.com/driftyco/ionic","homepage":"http://ionicframework.com/","size":84042,"stargazers_count":24060,"watchers_count":24060,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4768,"mirror_url":null,"open_issues_count":481,"forks":4768,"open_issues":481,"watchers":24060,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/6686"},"html":{"href":"https://github.com/driftyco/ionic/pull/6686"},"issue":{"href":"https://api.github.com/repos/driftyco/ionic/issues/6686"},"comments":{"href":"https://api.github.com/repos/driftyco/ionic/issues/6686/comments"},"review_comments":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/6686/comments"},"review_comment":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/driftyco/ionic/pulls/6686/commits"},"statuses":{"href":"https://api.github.com/repos/driftyco/ionic/statuses/9e22754c2c867629b3f1f8cfc6ab45783f6623c7"}}}}
{"actor":{"display_login":"adamdbradley"}}