Thursday, June 30, 2016

How can I stop my page from scrolling when I annotate on a touch device?

Leave a Comment

The problem is on this page: http://www.tagalogreader.com/document.php?id=28.

I'm using this: https://github.com/aron/annotator.touch.js with this https://github.com/openannotation/annotator.

There is one annoying bug that I have found when using my ipad. When I highlight some text and then click "annotate" the box pops up to write a note. That is desired. But what happens next is that somehow I'm automatically scrolled to the middle of the article even though I was highlighting something in the beginning of the article. So I just have to scroll back up.

How can I fix this problem?

1 Answers

Answers 1

Here is a plugin that disables the scrollbar when Annotator Editor is shown:

/** * Annotator Plugin to diasble scrollbar when Editor is shown */ Annotator.Plugin.DisableScroll = function (element, options) {   var myPlugin = {};   myPlugin.pluginInit = function () {     // This annotator instance     this.annotator         .subscribe("annotationEditorShown", function (editor, annotation) {           $(window).disablescroll();         })         .subscribe("annotationEditorHidden", function (editor) {           $(window).disablescroll("undo");         })   };   return myPlugin; }; 

It depends on the jQuery Plugin written by Josh Harrison.

Usage:

jQuery(function ($) {     $('#content').annotator().annotator('addPlugin', 'DisableScroll'); }); 

Demo: http://jsbin.com/saratucapa/1/edit?js,output

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment