angularjs - ionic scroll: Prevent translate3d on parent element -
i have template in ionic app looks this:
<ion-view> <ion-content> <div class="nav"> <span class="ion-chevron-left" ng-click="gotomonth('thismonth', $event)"></span> <span>{{ monthname }}</span> <span class="ion-chevron-right" ng-click="gotomonth('nextmonth', $event)"></span> </div> <ion-scroll on-scroll="onscroll()" class="wide-as-needed" delegate-handle="calendarscroll" direction="x" paging="true" scrollbar-x="false" style="min-height: 215px" ng-style="scrollstyle"> ...
the div class 'nav' contains 2 buttons let user switch between 2 months. months in <ion-scroll>
element.
this works should. buttons scroll <ion-scrol>
element horizontally. every time buttons used, entire <ion-view>
scrolled vertically down 20px - hiding buttons.
i've tried changing <ion-scroll>
s inline css (with angular.element
) not include 3d transforms, re-added.
this function gets called upon click - , attempt prevent transform3d
on parent element
$scope.gotomonth = function(id, event){ $location.hash(id); if(id == 'thismonth'){ $scope.monthname = monthlabels[thismonth]; } else{ $scope.monthname = monthlabels[nextmonth]; } var elm = angular.element(document.queryselector('.nav')); var parent = angular.element(elm.parent()); console.log(parent[0].style.transform); parent[0].style.transform = 'none'; $ionicscrolldelegate.anchorscroll(true); };
edit: i've tried using event.stoppropagation
- breaks functionality of <ion-scroll>
element
can tell me how prevent behaviour?
silly me. turns out simple solve. needed add scroll="false"
<ion-content>
element. no additional controller logic needed.
so html code above looks this:
<ion-view> <ion-content scroll="false">// <-- here altered html <div class="nav"> <span class="ion-chevron-left" ng-click="gotomonth('thismonth', $event)"></span> <span>{{ monthname }}</span> <span class="ion-chevron-right" ng-click="gotomonth('nextmonth', $event)"></span> </div> <ion-scroll on-scroll="onscroll()" class="wide-as-needed" delegate-handle="calendarscroll" direction="x" paging="true" scrollbar-x="false" style="min-height: 215px" ng-style="scrollstyle"> ...
Comments
Post a Comment