diff options
| author | ReAnzu | 2019-04-08 10:25:52 -0500 |
|---|---|---|
| committer | Marcin Kurczewski | 2019-04-08 21:36:48 +0200 |
| commit | a48116aa05b170fe6cbdbdf436e3057046bf1bbe (patch) | |
| tree | 0ec70a3f0f717cf03aaba1594e7f2c20bddd1100 /client/js/views | |
| parent | d69ef710b3e56d58b4dd40bb4ae1e19e5af0912f (diff) | |
client/post: Add swipe left and swipe right gestures to post content
client/post: Add swipe left and swipe right gestures to post content
Diffstat (limited to 'client/js/views')
| -rw-r--r-- | client/js/views/post_main_view.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/client/js/views/post_main_view.js b/client/js/views/post_main_view.js index 141de71..20f559d 100644 --- a/client/js/views/post_main_view.js +++ b/client/js/views/post_main_view.js @@ -5,6 +5,7 @@ const router = require('../router.js'); const views = require('../util/views.js'); const uri = require('../util/uri.js'); const keyboard = require('../util/keyboard.js'); +const Touch = require('../util/touch.js'); const PostContentControl = require('../controls/post_content_control.js'); const PostNotesOverlayControl = require('../controls/post_notes_overlay_control.js'); @@ -58,28 +59,38 @@ class PostMainView { this._installCommentForm(); this._installComments(ctx.post.comments); - keyboard.bind('e', () => { - if (ctx.editMode) { - router.show(uri.formatClientLink('post', ctx.post.id)); - } else { - router.show(uri.formatClientLink('post', ctx.post.id, 'edit')); - } - }); - keyboard.bind(['a', 'left'], () => { + const showPreviousImage = () => { if (ctx.prevPostId) { router.show(ctx.getPostUrl(ctx.prevPostId, ctx.parameters)); } - }); - keyboard.bind(['d', 'right'], () => { + }; + + const showNextImage = () => { if (ctx.nextPostId) { router.show(ctx.getPostUrl(ctx.nextPostId, ctx.parameters)); } + }; + + keyboard.bind('e', () => { + if (ctx.editMode) { + router.show(uri.formatClientLink('post', ctx.post.id)); + } else { + router.show(uri.formatClientLink('post', ctx.post.id, 'edit')); + } }); + keyboard.bind(['a', 'left'], showPreviousImage); + keyboard.bind(['d', 'right'], showNextImage); keyboard.bind('del', (e) => { if (ctx.editMode) { this.sidebarControl._evtDeleteClick(e); } }); + + new Touch( + postContainerNode, + showPreviousImage, + showNextImage + ) } _installSidebar(ctx) { |