Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page flip/turn on scroll up #71

Open
hitesh1989 opened this issue Mar 27, 2018 · 0 comments
Open

Page flip/turn on scroll up #71

hitesh1989 opened this issue Mar 27, 2018 · 0 comments

Comments

@hitesh1989
Copy link

Page flip while we scroll up by touch in ios.
I have implement this with angularjs.
`
var Page = (function() {

        var config = {                    
                $bookBlock : $( '#bb-bookblock' ),
                $navNext : $( '.bb-nav-next' ),
                $navPrev : $( '.bb-nav-prev' ),
                $navFirst : $( '#bb-nav-first' ),
                $navLast : $( '#bb-nav-last' )                    
            },
            init = function() {
                var startPage = ($rootScope.bookBlockStartPage!='' && $rootScope.bookBlockStartPage!=undefined)?$rootScope.bookBlockStartPage:1;
                console.log('startPage ' + startPage + ' = ' + $rootScope.bookBlockStartPage);
                config.$bookBlock.bookblock( {
                    startPage : startPage,
                    speed : 500,
                    shadowSides : 0.8,
                    shadowFlip : 0.4,
                    onBeforeFlip : function(currentpage) {               
                            window.scroll(0, 0);
                    },
                    onEndFlip : function(old, currentpage, isLimit) {  
                  },
                } );                     
                initEvents();
            },
            initEvents = function() {   
                 
                var $slides = config.$bookBlock.children();
                // add navigation events
                config.$navNext.on( 'click touchstart', function() {
                    config.$bookBlock.bookblock( 'next' );
                    return false;
                } );

                config.$navPrev.on( 'click touchstart', function() {
                    config.$bookBlock.bookblock( 'prev' );
                    return false;
                } );

                config.$navFirst.on( 'click touchstart', function() {
                    config.$bookBlock.bookblock( 'first' );
                    return false;
                } );

                config.$navLast.on( 'click touchstart', function() {
                    config.$bookBlock.bookblock( 'last' );
                    return false;
                } );

                // add swipe events
                $($slides).on( {
                    'swipeleft' : function( event ) {                                
                        config.$bookBlock.bookblock( 'next' );
                        return false;
                    },
                    'swiperight' : function( event ) {                               
                        config.$bookBlock.bookblock( 'prev' );
                        return false;
                    }
                } );

                // add keyboard events
                $( document ).keydown( function(e) {
                    var keyCode = e.keyCode || e.which,
                        arrow = {
                            left : 37,
                            up : 38,
                            right : 39,
                            down : 40
                        };

                    switch (keyCode) {
                        case arrow.left:
                            config.$bookBlock.bookblock( 'prev' );
                            break;
                        case arrow.right:
                            config.$bookBlock.bookblock( 'next' );
                            break;
                    }
                } );
                
           
            };
            return { init : init };

    })();
    Page.init();
   `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant