| |   |
| Name: Launcher: Reset to Middle Page |
| Version: 1.3.1-27 |
| Author: Ian Grant |
| Description: Resets the launcher when closing so that it always opens to the middle page, rather than the last page used. Obviously this works best with an odd number of pages (like the default 3). It also scrolls each page back to the top. (MIT license) |
|
| 1 | 6 | --- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.orig Sat Dec 5 11:48:12 2009 |
| 2 | 7 | +++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Thu Dec 3 19:42:03 2009 |
| @@ -183,6 +183,22 @@ |
| @@ -183,6 +183,25 @@ |
| 4 | 9 | delete this.launchRequest; |
| 5 | 10 | |
| 6 | 11 | this.removeLaunchFeedback(); |
| … | … | |
| 17 | 17 | + var numPages=this.pagesModel.getNumPages(); |
| 18 | 18 | + var middlePage = (numPages % 2) ? (numPages - 1) / 2: numPages / 2 - 1; |
| 19 | 19 | + |
| + /* Reset launcher to middle page */ |
| + /* Reset launcher to middle page - seems we need to do scrollTo AND setSnapIndex to be fully compatible with Wrap Pages */ |
| + $('launcher_root').mojo.scrollTo((middlePage) * -this.kPageWidth, undefined, false, true); |
| + this.activePageIndex = Math.abs($('launcher_root').mojo.getScrollPosition().left) / this.kPageWidth; |
| 21 | 23 | + $('launcher_root').mojo.setSnapIndex(middlePage, false); |
| + this.updatePageIndicators(); |
| 22 | 25 | + |
| 23 | 26 | + /* Jump scroll position back to top for all pages */ |
| 24 | 27 | + for (var i=0; i<numPages; i++) { |
| … | … | |
| 31 | 31 | }, |
| 32 | 32 | |
| 33 | 33 | onResize: function(event) { |
| @@ -529,6 +545,15 @@ |
| @@ -529,6 +545,18 @@ |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | this.globalSearchAssistant.enable(true); |
| … | … | |
| 42 | 42 | + */ |
| 43 | 43 | + var middlePage = (numPages % 2) ? (numPages - 1) / 2: numPages / 2 - 1; |
| 44 | 44 | + |
| + /* Set launcher to middle page */ |
| + /* Set launcher to middle page - seems we need to do scrollTo AND setSnapIndex to be fully compatible with Wrap Pages */ |
| + $('launcher_root').mojo.scrollTo((middlePage) * -this.kPageWidth, undefined, false, true); |
| + this.activePageIndex = Math.abs($('launcher_root').mojo.getScrollPosition().left) / this.kPageWidth; |
| 46 | 48 | + $('launcher_root').mojo.setSnapIndex(middlePage, false); |
| + this.updatePageIndicators(); |
| 47 | 50 | }, |
| 48 | 51 | |
| 49 | 52 | /* re-acquires the set of page elements the scroller needs to snap */ |