Comments (8)
+1
from onsenui.
I've added a simple (and maybe ugly) ability to cache pages in Sliding Menu, by adding the code below to scope.ons.slidingMenu.setAbovePage:
scope.ons.slidingMenu.setAbovePage = function (pageUrl) {
if (this.currentPageUrl === pageUrl) {
// same page -> ignore
return;
}
if (pageUrl) {
var cachedPage = this.cachedPages[pageUrl];
if (!cachedPage) {
$http({
url: pageUrl,
method: "GET"
}).error(function (e) {
console.error(e);
}).success(function (data, status, headers, config) {
var templateHTML = angular.element(data.trim());
var pageElement = angular.element('<div></div>');
pageElement.addClass('page');
pageElement[0].style.opacity = 0;
var pageContent = $compile(templateHTML)(scope);
pageElement.append(pageContent);
this.$abovePage.append(pageElement);
this.cachedPages[config.url] = pageElement;
// prevent black flash
setTimeout(function () {
pageElement[0].style.opacity = 1;
if (this.currentPageElement) {
// this.currentPageElement.remove();
this.currentPageElement.addClass('hiddenView');
}
this.currentPageElement = pageElement;
}.bind(this), 0);
this.currentPageUrl = pageUrl;
}.bind(this));
} else {
// We opt for the cached version of the page
// this.$abovePage.append(cachedPage);
cachedPage.removeClass('hiddenView');
setTimeout(function () {
cachedPage[0].style.opacity = 1;
if (this.currentPageElement) {
//this.currentPageElement.remove();
this.currentPageElement.addClass('hiddenView');
}
this.currentPageElement = cachedPage;
}.bind(this), 0);
this.currentPageUrl = pageUrl;
}
} else {
throw new Error('cannot set undefined page');
}
}.bind(this);
css
.hiddenView {
display: none;
}
I'm not removing the page from the dom, but instead hiding it. If the page is removed (instead of hidden), attached bindings stop working (for example, if the page has an ons-navigator-toolbar, click on buttons will not work if you open a cached page).
The dom gets bigger, but on the other hand, we just want to cache pages to where we navigate often, so there's a perceived performance increase.
from onsenui.
Great job!!
👍
from onsenui.
Hey @kruyvanna , I guess you'll like this: our app built with OnsenUI is now available in App Store and Google Play:
https://itunes.apple.com/en/app/boonzi-personal-finance/id808920979
https://play.google.com/store/apps/details?id=com.boonzi.mobile
The fix I proposed in this issue is working just fine in this app, along with the changes you did in the navigation branch. :)
from onsenui.
@JoaoSaleiro : wow this is amazing!!! 👍
We want to request your permission to feature your app in our company showcase page.
http://monaca.mobi/en/showcase
Also if you like, you can write a blog about your app in our blog.
http://blog.onsenui.io
Again, great job!!
from onsenui.
By the way, we searched for the app in Japan's Google Play, but it's not there.
We can find the web version but it say it's not compatible with our Nexus 7 device.
from onsenui.
Hey @kruyvanna, sorry for the late answer.
We're spamming this Github issue - here goes my email: joao [dot] saleiro [at] webfuel [dot] pt
:)
Drop me an email, I'll be glad to provide any info you need !
from onsenui.
great!
from onsenui.
Related Issues (20)
- In-docs Voice/Text Chat 🤩
- Vue3 | Page issue: HOT 3
- Core | issue: ons-input type="file" multiple does not work on macOS HOT 2
- Ons-splitter-mask Not Being Registered HOT 3
- Vue Onsen UI | Peer dependency for Vue 2 is still ~2.6.0 HOT 2
- Can OnsenUI2 run angular.js and Vue3 side by side? HOT 2
- swiperjs and React: Uncaught (in promise) TypeError: Cannot read properties of null (reading 'classList') HOT 5
- 500 Origin Error HOT 2
- Vue | Popover issue: JavaScript Error When Clicking Popover Component Consecutively in onsenUI Versions 2.12.x and Above HOT 3
- Angular1 | Splitter issue: Memory Leak HOT 2
- Error installing vue-onsenui via npm HOT 3
- ons-popover non-functional in Chrome since April 23, 2023 HOT 2
- ionic icons don't work HOT 2
- Angular Ivy Error HOT 2
- v-ons-speed-dial-item component that traverses multiple ICONS and is not fully displayed in the browser HOT 2
- Sponsoring OnsenUI? HOT 3
- Ty HOT 2
- Wrong page element returned, when inserting several pages HOT 1
- does not support angular v17
- ONSEN UI via cdn issue ? my ui in web its break today ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onsenui.