Difference between revisions of "Patch Launcher Reset Scroll on Page Change"

From WebOS Internals
Jump to navigation Jump to search
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{template:patch}}
 
{{template:patch}}
 +
 +
This is only for webOS 1.4.5 or lower. webOS 2.x and higher have a different launcher implementation that will not work with this patch.
 
==Introduction==
 
==Introduction==
  
 
If you have many apps on a page, you may have to scroll to see some of those. The launcher maintains the scroll state (the amount you have scrolled) on each page, which means when you return to a page, you are still at the location that you last scrolled to. This can be annoying. For example, it can make it difficult to train your muscle memory because, when repeating the same steps, the app you want is not always at the same location on the screen. This patch resets the scroll of each page back to the top when it goes out of view.
 
If you have many apps on a page, you may have to scroll to see some of those. The launcher maintains the scroll state (the amount you have scrolled) on each page, which means when you return to a page, you are still at the location that you last scrolled to. This can be annoying. For example, it can make it difficult to train your muscle memory because, when repeating the same steps, the app you want is not always at the same location on the screen. This patch resets the scroll of each page back to the top when it goes out of view.
  
'''Anyone have any luck with this?  It's not doing a thing for me.'''
+
Update Dec '09: I've changed the way the patch is implemented, this new version is now compatible with the Wrap Pages patch.
  
 
==Editing Process==
 
==Editing Process==
Line 17: Line 19:
 
sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
 
sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
 
</source></blockquote>
 
</source></blockquote>
* Locate the onPageChange method around line 157:
+
* Locate the end of the setup method, around line 98:
 +
<blockquote><source lang="javascript">
 +
// setup the initial dimensions for launcher/global-search
 +
this.adjustLayout();
 +
},
 +
 +
ready: function() {
 +
this.globalSearchAssistant.ready();
 +
},
 +
</source></blockquote>
 +
* Add the lines below to the end of the setup method (that is, make sure they're inside the '},' before the ready method on line 102), so that it now looks like this:
 
<blockquote><source lang="javascript">
 
<blockquote><source lang="javascript">
onPageChange: function(event) {
+
// setup the initial dimensions for launcher/global-search
this.activePageIndex = event.value;
+
this.adjustLayout();
this.updatePageIndicators();
+
 
},
+
// add a separate listener for resetting the scroll position on page changes, and also on deactivate
 +
Mojo.listen($('launcher_root'), Mojo.Event.propertyChange, this.resetScrollPosition.bindAsEventListener(this));
 +
Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.resetScrollPosition.bindAsEventListener(this));
 +
},
 +
 +
ready: function() {
 +
this.globalSearchAssistant.ready();
 +
},
 
</source></blockquote>
 
</source></blockquote>
* Add the four lines below so that onPageChange now looks like the following:
+
* Add the following method somewhere else in the file, I suggest just below the ready method and before the deleteAllPages method, around line 105 (don't forget the comma after the closing brace, unless you add it right at the end of the class, as the last method):
 
<blockquote><source lang="javascript">
 
<blockquote><source lang="javascript">
onPageChange: function(event) {
+
resetScrollPosition: function(event) {
var scroller = this.getPageScroller();
+
var pageIndex = (event.type === 'mojo-event-deactivate') ? this.activePageIndex : event.value;
if (scroller && scroller.mojo) {
+
var scroller = this.getPageScroller(pageIndex);
scroller.mojo.revealTop(0);
+
if (scroller && scroller.mojo) { scroller.mojo.revealTop(); }
}
+
},
this.activePageIndex = event.value;
 
this.updatePageIndicators();
 
},
 
 
</source></blockquote>
 
</source></blockquote>
 
* Save the file and quit vi.
 
* Save the file and quit vi.
Line 44: Line 60:
 
==Patch Process==
 
==Patch Process==
  
The patch should soon be located in the webos-internals gitorious repository. Until then, you can copy and paste the source below. Visit [[Applying Patches]] for info on how to use it. To apply the patch, follow the instructions above, and after remounting the filesystem as read/write, do the following:
+
An older version of the patch is in the git/Preware repository, hopefully this version will be submitted soon. Until then, you can copy and paste the source below. Visit [[Applying Patches]] for info on how to use it. You can also apply it using webOS Quick Install. To apply the patch, follow the instructions above, and after remounting the filesystem as read/write, do the following:
  
 
* Apply the patch (In this example, I have the patch file located in my home directory under '''patches'''):
 
* Apply the patch (In this example, I have the patch file located in my home directory under '''patches'''):
Line 62: Line 78:
  
 
<source lang="diff">
 
<source lang="diff">
--- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.bak 2009-05-22 17:12:34.000000000 -0400
+
--- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.orig Sat Dec  5 11:48:12 2009
+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js 2009-08-21 17:19:48.426297000 -0400
+
+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Thu Dec  3 19:42:03 2009
@@ -155,6 +155,10 @@
+
@@ -98,5 +98,9 @@
 +
// setup the initial dimensions for launcher/global-search
 +
this.adjustLayout();
 +
+
 +
+ // add a separate listener for resetting the scroll position on page changes, and also on deactivate
 +
+ Mojo.listen($('launcher_root'), Mojo.Event.propertyChange, this.resetScrollPosition.bindAsEventListener(this));
 +
+ Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.resetScrollPosition.bindAsEventListener(this));
 +
},
 
 
 
 
  /* keep track of which page we are on */
+
  ready: function() {
onPageChange: function(event) {
+
@@ -188,6 +188,12 @@
+       var scroller = this.getPageScroller();
+
onResize: function(event) {
+        if (scroller && scroller.mojo) {
+
  this.adjustLayout();
+            scroller.mojo.revealTop(0);
 
+        }
 
this.activePageIndex = event.value;
 
  this.updatePageIndicators();
 
 
  },
 
  },
 +
 +
+ resetScrollPosition: function(event) {
 +
+ var pageIndex = (event.type === 'mojo-event-deactivate') ? this.activePageIndex : event.value;
 +
+ var scroller = this.getPageScroller(pageIndex);
 +
+ if (scroller && scroller.mojo) { scroller.mojo.revealTop(); }
 +
+ },
 +
+
 +
/* remove page data and their corresponding HTML */
 +
deleteAllPages: function() {
 +
 +
 
</source>
 
</source>

Latest revision as of 01:42, 22 August 2011


This is only for webOS 1.4.5 or lower. webOS 2.x and higher have a different launcher implementation that will not work with this patch.

Introduction

If you have many apps on a page, you may have to scroll to see some of those. The launcher maintains the scroll state (the amount you have scrolled) on each page, which means when you return to a page, you are still at the location that you last scrolled to. This can be annoying. For example, it can make it difficult to train your muscle memory because, when repeating the same steps, the app you want is not always at the same location on the screen. This patch resets the scroll of each page back to the top when it goes out of view.

Update Dec '09: I've changed the way the patch is implemented, this new version is now compatible with the Wrap Pages patch.

Editing Process

  • SSH in.
  • Remount the filesystem as read/write:

<source lang="bash">

sudo rootfs_open -w

</source>

  • Load launcher-assistant.js in vi:

<source lang="bash">

sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js

</source>

  • Locate the end of the setup method, around line 98:

<source lang="javascript">

// setup the initial dimensions for launcher/global-search this.adjustLayout(); },

ready: function() { this.globalSearchAssistant.ready(); },

</source>

  • Add the lines below to the end of the setup method (that is, make sure they're inside the '},' before the ready method on line 102), so that it now looks like this:

<source lang="javascript">

// setup the initial dimensions for launcher/global-search this.adjustLayout();

// add a separate listener for resetting the scroll position on page changes, and also on deactivate Mojo.listen($('launcher_root'), Mojo.Event.propertyChange, this.resetScrollPosition.bindAsEventListener(this)); Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.resetScrollPosition.bindAsEventListener(this)); },

ready: function() { this.globalSearchAssistant.ready(); },

</source>

  • Add the following method somewhere else in the file, I suggest just below the ready method and before the deleteAllPages method, around line 105 (don't forget the comma after the closing brace, unless you add it right at the end of the class, as the last method):

<source lang="javascript">

resetScrollPosition: function(event) { var pageIndex = (event.type === 'mojo-event-deactivate') ? this.activePageIndex : event.value; var scroller = this.getPageScroller(pageIndex); if (scroller && scroller.mojo) { scroller.mojo.revealTop(); } },

</source>

  • Save the file and quit vi.
  • Remount the filesystem as read only - this should reboot your Pre:

<source lang="bash">

sudo rootfs_open -w

</source>


Patch Process

An older version of the patch is in the git/Preware repository, hopefully this version will be submitted soon. Until then, you can copy and paste the source below. Visit Applying Patches for info on how to use it. You can also apply it using webOS Quick Install. To apply the patch, follow the instructions above, and after remounting the filesystem as read/write, do the following:

  • Apply the patch (In this example, I have the patch file located in my home directory under patches):

<source lang="bash">

cd / sudo patch -p0 --backup-if-mismatch < ~/patches/reset-scroll.patch

</source>

This is what you should see if it ran properly: <source lang="text"> patching file /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js

</source>

  • Remount the filesystem as read only as described above.


Patch Source (reset-scroll.patch)

<source lang="diff"> --- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.orig Sat Dec 5 11:48:12 2009 +++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Thu Dec 3 19:42:03 2009 @@ -98,5 +98,9 @@

		// setup the initial dimensions for launcher/global-search
		this.adjustLayout();

+ + // add a separate listener for resetting the scroll position on page changes, and also on deactivate + Mojo.listen($('launcher_root'), Mojo.Event.propertyChange, this.resetScrollPosition.bindAsEventListener(this)); + Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.resetScrollPosition.bindAsEventListener(this));

	},
	
	ready: function() {	

@@ -188,6 +188,12 @@

	onResize: function(event) {
		this.adjustLayout();
	},

+ resetScrollPosition: function(event) { + var pageIndex = (event.type === 'mojo-event-deactivate') ? this.activePageIndex : event.value; + var scroller = this.getPageScroller(pageIndex); + if (scroller && scroller.mojo) { scroller.mojo.revealTop(); } + }, +

	/* remove page data and their corresponding HTML */
	deleteAllPages: function() {


</source>