Ionic transition from one page to other page flicker.
Ionic transition from one page to other page flicker. i am using gradient color for ion-content. and i have set $watch for some variables. also data are dynamic loading. sliding tabs are used. can let me what will be the issue for page flicker. please help me
Any example code to show, or more info (device/platform/etc.)? As such we cannot help.
I am using in android platform. when done a click from home page to product page(below shown). page flickers. and when i click back button it repeat 2 times same page. and ionic history is working for one view in mobile. in brower it is working perfectly. in mobile history is different
html part:
<tab-slide-box id="tabslideshop" tab="0">
<div class="tsb-icons">
<div class="tsb-ic-wrp">
<ion-scroll direction="x" delegate-handle="my-productslide" class="tsb-hscroll">
<a class="ion-home1">Featured</a>
<a class="ion-home1">All Products</a>
<a class="ion-ios-game-controller-b1">All Services</a>
<a class="ion-home1">Trending Now</a>
</ion-scroll>
</div>
</div>
<ion-slide-box show-pager="false" delegate-handle="my-productslide" on-slide-changed="slideHasChanged($index); slideHasservice($index);">
<ion-slide >
<div ng-include="'templates/Shops/shopproductFeatured.html'" ></div>
</ion-slide>
<ion-slide >
<div ng-include="'templates/Shops/shopproduct.html'" ></div>
</ion-slide>
<ion-slide >
<div ng-include="'templates/Shops/shopservice.html'" ></div>
</ion-slide>
<ion-slide >
<div ng-include="'templates/Shops/shopproductTrending.html'" ></div>
</ion-slide>
</ion-slide-box>
</tab-slide-box>
js part:
.controller('ShopProductCtrl', function($scope, $rootScope, $state, $ionicLoading, slideindexvaluereturn, PostService, AuthService, $ionicPopup, $stateParams, ShopsService, $ionicScrollDelegate, PostProductService, $timeout, CharityCategoryService, pagenotfound, $ionicModal, $ionicSlideBoxDelegate, $cacheFactory, productserviceconstant, $ionicModal) { //------------------------product details functions----------------------------------- $scope.postidgl = [];
$scope.setshop = function(val) {
if (val == 1) {
$scope.selectedshop = false;
$scope.prodactive = "active";
$scope.shopactive = "";
$scope.doGetPost($scope.postidgl);
} else {
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 30000
});
ShopsService.getShopDetails($scope.postidgl.author).then(function(data) {
$ionicLoading.hide();
$scope.bannerimage = data.banner_url;
$scope.shopdetails = data;
console.log($scope.shopdetails.phone);
});
$scope.selectedshop = true;
$scope.prodactive = "";
$scope.shopactive = "active";
}
};
var postId = $scope.postidgl;
$scope.doRefresh();
$scope.repeatDone = function() {
$ionicSlideBoxDelegate.update();
//$ionicSlideBoxDelegate.slide($scope.week.length - 1, 1);
};
$scope.givestar = function(id) {
$(id).toggleClass("staricon");
}
$scope.addreview = function(reviewtext) {
var star = "staricon";
var k = 0;
for (i = 1; i < 6; i++) {
var classvalue = $('#star' + i).attr('class');
if (classvalue.indexOf(star) != -1) {
k++;
}
}
PostProductService.setReview($scope.postidgl.id, reviewtext, k).then(function(data) {
$ionicPopup.alert({
title: "Successfully Added"
});
});
}
$scope.doGetPost = function(post) {
$scope.postidgl = post;
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 30000
});
PostProductService.getPost($scope.postidgl.id, "product")
.then(function(data) {
console.log(data);
$scope.post = data.product;
if ($scope.post.featured_src == false) {
$scope.post.featured_src = 'img/logo1.png';
}
console.log(data);
PostProductService.getPostReviews($scope.postidgl.id).then(function(data) {
console.log(data);
$scope.productreviews = data.product_reviews;
console.log(data);
$ionicLoading.hide();
});
});
}
//----------------------------------------------------------------------
$ionicModal.fromTemplateUrl('templates/Shops/productdetails.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modalproductdetails = modal;
});
$scope.productdetails = function(post) {
$scope.postidgl = post;
$scope.post = [];
$scope.bannerimage = '';
$scope.shopdetails = [];
$scope.selectedshop = false;
$scope.prodactive = "active";
$scope.shopactive = "";
$scope.setshop(1);
$scope.modalproductdetails.show();
}
$scope.closesinglepostpopup = function(post) {
$scope.modalproductdetails.hide();
}
//---------------------------------------------------------------------------
$scope.productservice = productserviceconstant;
console.log($scope.productservice);
if ($stateParams.tabid == 1) {
//$ionicSlideBoxDelegate.$getByHandle('my-productslide').start();
$scope.tabid = 1;
}
$scope.tabid = 0;
if ($stateParams.tabid == undefined) {
$scope.tabid = 0;
} else {
$scope.tabid = $stateParams.tabid;
}
$scope.getselectedclass = function(id) {
var c = '#shoppscat';
for (i = 0; i < $scope.category.length; i++) {
c = '#shoppscat';
c = c.concat(i + 1);
$(c).removeClass("activatedtab");
console.log();
}
c = '#shoppscat';
c = c.concat(id);
$(c).addClass("activatedtab");
}
$scope.dogetshop = function() {
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 15000
});
ShopsService.getShopDetails($stateParams.userid).then(function(data) {
$ionicLoading.hide();
console.log(data);
if (data.status == "error") {
$scope.doRefresh();
}
if (data.terms != undefined) {
var category = [];
for (i = 0; i < data.terms.length; i++) {
console.log(data.terms[i]);
category.push({
id: data.terms[i].term_id,
title: data.terms[i].name
});
}
$scope.category = category;
}
});
}
$scope.dogetshop();
$scope.dogetserviceCategory = function() {
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 15000
});
$scope.pagesh = 1;
CharityCategoryService.getCharitytxCategories('service_types', 1, $scope.parentidssh)
.then(function(data) {
$ionicLoading.hide();
if (data.categories.length > 0) {
$scope.servicecategory = data.categories
}
console.log($scope.servicecategory);
$scope.$broadcast('scroll.refreshComplete');
});
}
$scope.gotocatscrollsublevel = function(cat, id) {
console.log(cat);
if (id == 0) {
$scope.searchcat = null;
$scope.dogetshop();
} else {
if (cat.child_count == undefined) {
$scope.parentidsh = cat.id;
$scope.getpssubcategory();
} else {
$scope.searchcat = cat.slug;
}
}
$scope.doRefresh();
}
$scope.pagesh = 1;
$scope.getpssubcategory = function() {
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 15000
});
$scope.pagesh = 1;
CharityCategoryService.getCharitytxCategories('shop_types', 1, $scope.parentidsh)
.then(function(data) {
$scope.sublevel = 0;
$ionicLoading.hide();
if (data.categories.length > 0) {
$scope.category = data.categories
}
console.log($scope.category);
$scope.$broadcast('scroll.refreshComplete');
});
}
$scope.functionsearchcat = function(post) {
if (($scope.tabid == 1) || ($scope.tabid == 2)) {
if ($scope.test != 0) {
var value = false;
if (($scope.test != 3)) {
$scope.test = 0;
}
if (post.shoptypes.length > 0) {
for (i = 0; i < post.shoptypes.length; i++) {
if (post.shoptypes[i].slug == $scope.searchcat) {
value = true;
$scope.test = 3;
}
}
}
if ($scope.searchcat == undefined) {
$scope.test = 3;
value = true;
}
console.log($scope.searchcat);
console.log($scope.test);
return value;
}
}
}
//shopcategory popup
$ionicModal.fromTemplateUrl('templates/Shops/partials/showcategorypopup.html', {
scope: $scope
}).then(function(modal) {
$scope.modalshc = modal;
});
//shopservicecategory popup
$ionicModal.fromTemplateUrl('templates/Shops/partials/showservicecategorypopup.html', {
scope: $scope
}).then(function(modal) {
$scope.modalsshc = modal;
});
$scope.doSelectCategory = function() {
if ($scope.tabid == 1) {
$scope.sublevel = 1;
$scope.dogetshop();
$scope.modalshc.show();
} else if ($scope.tabid == 2) {
$scope.parentidssh = 0;
$scope.dogetshop();
// $scope.dogetserviceCategory();
$scope.modalsshc.show();
}
}
$scope.closeservicecatpopup = function() {
$scope.modalsshc.hide();
}
$scope.closecatpopup = function() {
$scope.modalshc.hide();
}
var user = JSON.parse(localStorage.getItem('ionWordpress_user'));
console.log(user);
if (localStorage.getItem('ionWordpress_user') != null) {
$scope.currentuser = user.user_id;
} else {
$scope.currentuser = 0;
}
$scope.slideHasservice = function(index) {
$scope.test = 1;
$scope.indextab = index;
if (index == 0) {
$scope.tabid = 0;
$scope.producttype = "featured";
} else if (index == 1) {
$scope.tabid = 1;
$scope.producttype = "product";
} else if (index == 2) {
$scope.tabid = 2;
$scope.producttype = "service";
} else if (index == 3) {
$scope.tabid = 3;
$scope.producttype = "trending";
}
console.log($scope.producttype);
$scope.doRefresh();
slideindexvaluereturn.setslidei(index);
}
$scope.favourBoxpopup = function(varid, post, authorname, authorid) {
var rate = post.sale_price;
if (varid != -1) {
rate = post.variations[0].sale_price;
}
var itemcount = $scope.eachitemdetailsingle(varid, post.id, rate, 2, 0);
if (itemcount == 0) {
itemcount = 1;
}
$scope.productdaily = [];
$scope.productweekly = [];
$scope.productmonthly = [];
// An elaborate, custom popup
var myPopup = $ionicPopup.show({
title: 'Categories',
subTitle: 'Please select',
scope: $scope,
buttons: [{
text: 'Cancel',
type: 'button-assertive',
onTap: function(e) {
myPopup.close();
}
}, {
text: 'Daily Needs',
onTap: function(e) {
if (localStorage.getItem('productdaily') != null) {
$scope.productdaily = JSON.parse(localStorage.getItem('productdaily'));
}
for (i = 0; i < itemcount; i++) {
$scope.productdaily.push({
"prod_name": post.title,
"cat_id": varid,
"prod_id": post.id,
"rate": rate,
"quantity": 2,
"image": post.featured_src,
"authorname": authorname,
"authorid": authorid
});
}
localStorage.setItem('productdaily', JSON.stringify($scope.productdaily));
myPopup.close();
$ionicPopup.show({
title: 'Add to List',
template: 'Successfully Added',
buttons: [{
text: 'Ok'
}, {
text: '<b>Goto My List</b>',
type: 'button-positive',
onTap: function(e) {
$scope.modalproductdetails.hide();
$state.go("app.myneeds", {
needtype: 'productdaily'
});
}
}]
});
}
}, {
text: 'Weekly Needs',
type: 'button-assertive',
onTap: function(e) {
if (localStorage.getItem('productweekly') != null) {
$scope.productweekly = JSON.parse(localStorage.getItem('productweekly'));
}
for (i = 0; i < itemcount; i++) {
$scope.productweekly.push({
"prod_name": post.title,
"cat_id": varid,
"prod_id": post.id,
"rate": rate,
"quantity": 2,
"image": post.featured_src,
"authorname": authorname,
"authorid": authorid
});
}
localStorage.setItem('productweekly', JSON.stringify($scope.productweekly));
myPopup.close();
$ionicPopup.show({
title: 'Add to List',
template: 'Successfully Added',
buttons: [{
text: 'Ok'
}, {
text: '<b>Goto My List</b>',
type: 'button-positive',
onTap: function(e) {
$scope.modalproductdetails.hide();
$state.go("app.myneeds", {
needtype: 'productweekly'
});
}
}]
});
}
}, {
text: 'Monthly Needs',
type: 'button-positive',
onTap: function(e) {
if (localStorage.getItem('productmonthly') != null) {
$scope.productmonthly = JSON.parse(localStorage.getItem('productmonthly'));
}
for (i = 0; i < itemcount; i++) {
$scope.productmonthly.push({
"prod_name": post.title,
"cat_id": varid,
"prod_id": post.id,
"rate": rate,
"quantity": 2,
"image": post.featured_src,
"authorname": authorname,
"authorid": authorid
});
}
localStorage.setItem('productmonthly', JSON.stringify($scope.productmonthly));
myPopup.close();
$ionicPopup.show({
title: 'Add to List',
template: 'Successfully Added',
buttons: [{
text: 'Ok'
}, {
text: '<b>Goto My List</b>',
type: 'button-positive',
onTap: function(e) {
$scope.modalproductdetails.hide();
$state.go("app.myneeds", {
needtype: 'productmonthly'
});
}
}]
});
}
}]
});
myPopup.then(function(res) {
});
};
$scope.shopname = localStorage.getItem("shopname");
$scope.userid = $stateParams.userid;
$scope.productcatid = $stateParams.catid;
$scope.page = 1;
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 15000
});
$scope.pagenotfound = pagenotfound;
$scope.doRefresh = function() {
console.log($scope.tabid == '');
console.log($scope.producttype);
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>',
duration: 15000
});
$scope.featuredid = 'no';
var categoryidpro = $stateParams.catid;
if ($scope.tabid == 0) {
$scope.producttype = "";
$scope.featuredid = 'yes';
} else if ($scope.tabid == 1) {
$scope.producttype = "product";
} else if ($scope.tabid == 2) {
$scope.producttype = "service";
} else if ($scope.tabid == 3) {
categoryidpro = 11969;
$scope.producttype = "";
} else {
$scope.producttype = "";
}
$scope.page = 1;
ShopsService.getProductsfromShop($stateParams.userid, categoryidpro, 1, $scope.producttype, $scope.featuredid).then(function(data) {
$ionicLoading.hide();
if ($scope.tabid == 1) {
$scope.postspro = data.products;
} else if ($scope.tabid == 2) {
$scope.products = data.products;
} else if ($scope.producttype == "") {
$scope.postsfeatured = data.products;
console.log($scope.postsfeatured);
} else if ($scope.tabid == 3) {
$scope.poststrending = data.products;
}
if (data.products.length == 0) {
$scope.test = 0;
} else {
$scope.test = 1;
}
}).finally(function() {
$scope.$broadcast('scroll.refreshComplete');
})
};
$scope.loadMoreData = function() {
var categoryidpro = $stateParams.catid;
if ($scope.tabid == 3) {
categoryidpro = 11969;
}
$scope.page += 1;
ShopsService.getProductsfromShop($stateParams.userid, categoryidpro, $scope.page, $scope.producttype, $scope.featuredid).then(function(data) {
$ionicLoading.hide();
if (($scope.producttype == "product") && ($scope.postspro != undefined)) {
$scope.postspro = $scope.postspro.concat(data.products);
} else if (($scope.producttype == "service") && ($scope.products != undefined)) {
console.log(data.products);
$scope.products = $scope.products.concat(data.products);
} else if (($scope.producttype == "featured") && ($scope.products != undefined)) {
console.log(data.products);
$scope.postsfeatured = $scope.postsfeatured.concat(data.products);
} else if (($scope.producttype == "trending") && ($scope.products != undefined)) {
console.log(data.products);
$scope.poststrending = $scope.poststrending.concat(data.products);
}
if (data.products.length < 1) {
$scope.page = 0;
}
$scope.$broadcast('scroll.infiniteScrollComplete');
});
};
$scope.moreDataCanBeLoaded = function() {
var value = true;
if ($scope.page == 0) {
value = false;
}
return value;
};
$scope.changejson = function() {
$scope.separateArray = [];
angular.forEach($scope.itemdetails, function(item, i) {
var foundItem = false; // track if an item exists in your new array
if ($scope.separateArray.length > 0) {
angular.forEach($scope.separateArray, function(newitem, y) {
if ((newitem.prod_id == item.prod_id) && (newitem.cat_id == item.cat_id)) {
foundItem = true; // notify that the item is found and we dont have to add it
}
});
}
if (!foundItem) { // if no item is found
$scope.separateArray.push({
"prod_name": item.prod_name,
"cat_id": item.cat_id,
"prod_id": item.prod_id,
"rate": item.rate,
"quantity": item.quantity,
"image": item.image,
"authorname": item.authorname,
"authorid": item.authorid
});
// push this item into our new array
}
});
}
$scope.addtocart = function(prod_name, cat_id, prod_id, rate, quantity, imageurl, authorname, authorid) {
$scope.itemdetails = [];
if (localStorage.getItem('products') != null) {
$scope.itemdetails = JSON.parse(localStorage.getItem('products'));
}
$scope.itemdetails.push({
"prod_name": prod_name,
"cat_id": cat_id,
"prod_id": prod_id,
"rate": rate,
"quantity": quantity,
"image": imageurl,
"authorname": authorname,
"authorid": authorid
});
localStorage.setItem('products', JSON.stringify($scope.itemdetails));
$scope.changejson();
localStorage.setItem('separateArray', JSON.stringify($scope.separateArray));
};
$scope.removefromcart = function(prod_name, cat_id, prod_id, rate, quantity, imageurl, authorname, authorid) {
var i = 0;
angular.forEach($scope.itemdetails, function(todo) {
if ((todo.cat_id == cat_id) && (todo.prod_id == prod_id) && (todo.rate == rate) && (todo.quantity == quantity) && (i < $scope.itemdetails.length)) {
$scope.itemdetails.splice(i, 1);
i = $scope.itemdetails.length + 2;
}
i++;
});
localStorage.setItem('products', JSON.stringify($scope.itemdetails));
$scope.changejson();
localStorage.setItem('separateArray', JSON.stringify($scope.separateArray));
}
$scope.eachitemdetails = function(item, k) {
var eachitem = [];
var count = 0,
qty = 0,
rate = 0;;
angular.forEach($scope.itemdetails, function(todo) {
if ((todo.cat_id == item.cat_id) && (todo.prod_id == item.prod_id) && (todo.rate == item.rate) && (todo.quantity == item.quantity)) {
count++;
rate += eval(todo.rate);
qty += todo.quantity;
}
});
eachitem[0] = count;
eachitem[1] = rate;
eachitem[2] = qty;
return eachitem[k];
};
$scope.eachitemdetailsingle = function(cat_id, prod_id, rate, quantity, k) {
if (localStorage.getItem('products') != null) {
$scope.itemdetails = JSON.parse(localStorage.getItem('products'));
$scope.changejson();
}
var eachitem = [];
var count = 0,
qty = 0,
drate = 0;;
angular.forEach($scope.itemdetails, function(todo) {
if ((cat_id == todo.cat_id) && (prod_id == todo.prod_id) && (rate == todo.rate) && (quantity == todo.quantity)) {
count++;
drate += eval(todo.rate);
qty += todo.quantity;
}
});
eachitem[0] = count;
eachitem[1] = drate;
eachitem[2] = qty;
return eachitem[k];
};
$scope.itemcount = function() {
var count = 0;
angular.forEach($scope.itemdetails, function(todo) {
count++;
});
return count;
};
$scope.totalamount = function() {
var total = 0;
angular.forEach($scope.itemdetails, function(todo) {
total += eval(todo.rate);
});
return total;
};
$scope.deletebooklist = function(post) {
$scope.dailyneed = [];
$scope.dailyneednew = [];
$scope.weeklyneed = [];
$scope.weeklyneednew = [];
$scope.monthlyneed = [];
$scope.monthlyneednew = [];
$scope.dailyneed = JSON.parse(localStorage.getItem("productdaily"));
$scope.weeklyneed = JSON.parse(localStorage.getItem("productweekly"));
$scope.monthlyneed = JSON.parse(localStorage.getItem("productmonthly"));
angular.forEach($scope.dailyneed, function(item, k) {
if (item.prod_id == post.id) {} else {
$scope.dailyneednew.push($scope.dailyneed[k]);
}
});
angular.forEach($scope.weeklyneed, function(item, k) {
if (item.prod_id == post.id) {} else {
$scope.weeklyneednew.push($scope.weeklyneed[k]);
}
});
angular.forEach($scope.monthlyneed, function(item, k) {
if (item.prod_id == post.id) {} else {
$scope.monthlyneednew.push($scope.monthlyneed[k]);
}
});
localStorage.setItem("productdaily", JSON.stringify($scope.dailyneednew));
localStorage.setItem("productweekly", JSON.stringify($scope.weeklyneednew));
localStorage.setItem("productmonthly", JSON.stringify($scope.monthlyneednew));
}
$scope.gotoeditpost = function(post) {
if (post.product_type == "service") {
$state.go('app.createpost', {
postid: post.id
});
} else {
$state.go('app.addproduct', {
postid: post.id
});
}
}
$scope.deletePost = function(post) {
var confirmPopup = $ionicPopup.confirm({
title: 'POST DELETE',
template: 'Are you sure you want delete?'
});
confirmPopup.then(function(res) {
if (res) {
console.log(post, $stateParams.posttype);
PostProductService.deletePost(post, $stateParams.posttype).then(function(data) {
$ionicPopup.alert({
title: "Successfully Deleted"
});
$scope.deletebooklist(post);
$scope.doRefresh();
});
} else {}
});
};
})
Do i need to give some other information. i am a beginner in ionic developement. So please correct me. how to remove that flicker.
Hi @vaidyanathanas,
Please provide a very minimal example that demonstrates the problem in a codepen. Here are some starter codepens to help you out. http://codepen.io/ionic/pens/public/?grid_type=list
Thanks, Dan
Hello all! As it seems it has been a while since there was any activity on this issue i will be closing it for now. Feel free to comment if you are still running into this issue. Thanks for using Ionic!
@jgw96 I am having the issue too. It only happens on iOS 9&10. When I removed on-slide-changed attribute from ion-slide-box, the flickering is gone. On Android and PC, it works fine.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.