GithubHelp home page GithubHelp logo

ascensor.js's Introduction

Ascensor.js Build Status devDependency Status

Ascensor is a jquery plugin which aims to train and adapt content according to an elevator system (homepage)

Getting Started

Download the [production version][min] or the [development version][max]. [max]: https://raw.github.com/kirkas/Ascensor.js/master/dist/jquery.ascensor.js [min]: https://raw.github.com/kirkas/Ascensor.js/master/dist/jquery.ascensor.min.js

In your web page:

<div id="ascensor">
  <div>Content 1</div>
  <div>Content 2</div>
  <div>Content 3</div>
  <div>Content 4</div>
  <div>Content 5</div>
  <div>Content 6</div>  
  <div>Content 7</div>
</div>

<script src="jquery['>=1.7'].js"></script>
<script src="jquery.ascensor.js"></script>
<script>
  $('#ascensor').ascensor();
</script>

Public Methods

Note that to access public method, you need to access the instance store in the data attribute under the plugin name. This a behavior inherited from the jQuery boilerplate.

var ascensor = $('#ascensor').ascensor();           // Init ascensor
var ascensorInstance = ascensor.data('ascensor');   // Access instance

ascensorInstance.prev();                            // Go to previous floor
ascensorInstance.next();                            // Go to next floor

ascensorInstance.scrollToFloor(4);                  // Go to floor Index
ascensorInstance.scrollToFloor('content2');         // Go to floor Name

ascensorInstance.scrollToDirection('up');           // Go up
ascensorInstance.scrollToDirection('down');         // Go down
ascensorInstance.scrollToDirection('left');         // Go left
ascensorInstance.scrollToDirection('right');        // Go right

ascensorInstance.refresh();                         // Refresh floor position
ascensorInstance.destroy();                         // Remove plugin

Events

Ascensor emit two event, on scrollStart & scrollEnd, they both return an array with the original floor and the targeted floor.

var ascensor = $('#ascensor').ascensor();           // Init ascensor

ascensor.on("scrollStart", function(e, floor){
  console.log(floor.from)                           // Return the origin floor
  console.log(floor.to)                             // Return the targeted floor
});

ascensor.on("scrollEnd", function(e, floor){
  console.log(floor.from)                           // Return the origin floor
  console.log(floor.to)                             // Return the targeted floor
});

NEW! - Data attribute

Sometime you need a floor to behave differently in term of direction, you can now easily force this by adding a custom data-attribute on the dom element.

Here the available attribute:

data-ascensor-next
data-ascensor-prev
data-ascensor-up
data-ascensor-down
data-ascensor-left
data-ascensor-right

example:

<div id="ascensor"> 
  <div data-ascensor-left="3" >Content 1</div>   <!-- This will force the left key to scroll to the last floor -->
  <div>Content 2</div>
  <div>Content 3</div>
  <div data-ascensor-right="0" >Content 4</div>  <!-- This will force the right key to scroll to the first floor -->
</div>

NEW! - Swipe event

Ascensor now use hiw own swipe event system. Just set swipeNavigation to true, false or "mobile-only" (default).

Options

ascensorFloorName
Type: array of string
Default: null
descriptions: Choose and name for each floor, this name will be added in the url as #name
example: ascensorFloorName: ['content1','content2','content3']

childType
Type: string
Default: div
descriptions: Specify the child tag if no div ('section' or 'article')
example: childType:'article'

width
Type: integer or string
Default: "100%"
descriptions: the width of your floor (% or pixel)
example: width: "80%"

height
Type: integer or string
Default: "100%"
descriptions: the height of your floor (% or pixel)
example: height: "300px"

ready
Type: function
Default: false
descriptions: function to execute when ascensor is ready
example: ready: function(){ alert("ready") }

direction
Type: string or object
Default: 'y'
descriptions: specify the direction 'x', 'y' or and array of x/y position for each floor [[2,1],[2,2],[3,2]]
example: direction: [[2,1],[2,2],[3,2]]

time
Type: integer
Default: 300
descriptions: Specify speed of transition
example: time: 500

easing
Type: string
Default: linear
descriptions: Specify easing option (don't forget to add the easing plugin)
example: easing: 'easeInElastic'

swipeNavigation
Type: boolean or string
Default: mobile-only
descriptions: Specify if you want swipe navigation, you can set true, false or "mobile-only" (default)
example: swipeNavigation: true

keyNavigation
Type: boolean
Default: true
descriptions: choose if you want direction key support
example: keyNavigation: false

queued
Type: boolean or string
Default: false
descriptions: define queued transition.
false: transition will happen simultaneously for X and Y axis
"x": will animate on the X axis, then on the Y
"y": will animate on the Y axis, then on the X
example: queued: 'x'

jump
Type: boolean
Default: false
descriptions: Specify is you want ascensor to jump between floor, even if a gap is present between them
example: jump: true

wheelNavigation
Type: boolean
Default: false
descriptions: Set to true if you want mousescroll to trigger animation between floor
example: wheelNavigation: true

wheelNavigationDelay
Type: number
Default: 40
descriptions: Adjust to delay between mousewheel event to trigger animation
example: wheelNavigationDelay: 100

loop
Type: boolean
Default: true
descriptions: Specify if you want ascensor to loop once reach the end of an axis, There is six differents behavior for ascensor.
true: will reach the further floor on same axis once reach the end, on all axis
"loop-x": will reach the further floor on same axis once reach the end, only on X axis
"loop-y": will reach the further floor on same axis once reach the end, only on Y axis
"increment": will reach next same-axis floor level when reach end end, on all axis
"increment-x": will reach opposite floor on y axis, but jump to next level on X axis
"increment-y": will reach opposite floor on y axis, but jump to next level on Y axis
example: loop: increment-x

Demo & Examples

Note that all example are situated in the examples folder of the repository
Simple
Horizontal
Chocolat
Url
Swipe
Loop
Increment

Websites using ascensor

waterevive
shanaemairs
reverseburo
robclowes
iadindustry
newworldwhisky
lucasexbrayat
scan.dk
alpineconstruction.dk

####Contribution

You want help? great! For my workflow, I use grunt.js (require node & npm installed)

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add your change/fix
  4. Build project using "grunt build" (in terminal)
  5. Commit your change (only if "grunt build" return no error)
  6. Push to the branch (git push origin my-new-feature) & request pull request!

####Donation https://cash.me/$kirkas

####Author Léo Galley

ascensor.js's People

Contributors

kbredemeier avatar kirkas avatar kppf avatar liluxdev avatar soniumandy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ascensor.js's Issues

Integration with angular.js

Hi Léo,
thanks for your great animation script!
Do you see any possibility to get ascensor.js integrated with angular.js' ngAnimate and ngRoute?
The idea would be to define routing in a single page application via ngRoute and animate transitions via ascensor.js. Seems that there is already a hook for javascripts in ngAnimate (http://docs.angularjs.org/guide/animations). But how define the respective functions?
Thanks & Cheers, Chris.

Visual GitHub logo link on web page Request

BTW, just saw you made some improvements such as Touchswiping and Triggering.

May I suggest putting that GitHub logo link on the page. That would make it easy for users to find. Though I know its there I often miss the text link on the home page though it is obvious. But, after being on the page so many times I think I 'know' whats on the homepage and I don't get that Visual Cue with the link if you know what I mean.

Regards,
Brian

Get current floor

It could be fine to have a method to get the current floor. Maybe it's already possible : how to get the value of windowsOn property ?

scrollToFloorName function / Trigger request

Léo:

Can a trigger named 'scrollToFloorName' be added? Here is the code I use:

    var $aryAscensorFloorName = ['Home','Product','Services','Activity','Home2','Product2','Services2','Activity2','Home3','Product3','Services3','Activity3'];
    var $aryAscensorDirection = [[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]];

    var ascensor = $('#ascensorBuilding').ascensor({
        childType: 'section',
        ascensorFloorName: $aryAscensorFloorName,
        time: 250,
        windowsOn: 0,
        direction: $aryAscensorDirection,
        directionStart: "y",
        easing: 'easeInOutQuad',
        keyNavigation: true,
        loop: true,
        queued: 0,
        overflow:"hidden"
    });
    function scrollToFloorName($floorName) {
        try {
            ascensor.trigger("scrollToStage", $.inArray($floorName, $aryAscensorFloorName));
        }
        catch(err) {
              txt="The requested floor [" + $floorName +  "] does not exist. \n\n";
              txt += "Click OK to continue.\n\n";
              alert(txt);
        }
    }

An example of actioning this is:

  <div onclick="scrollToFloorName('Product')">Home</div>

Of course the try/catch is not required, without it if the floorName is not found nothing will happen.

Position top and left

I am seeing the new options for width and height. Can the option for top and left also be added?

I am making the change in my code but was wondering if it can also be added to the code on your end.

      // Setup floor size & position
      this.node.css({
        'position': 'absolute',
        'overflow': 'hidden',
        'top': '100px',
        'left': '100px',
        'width': this.options.width,
        'height': this.options.height
      });

I have changed to the following and added the options accordingly and it appears to work fine and not break the code any. Is this all I need to do?

      // Setup floor size & position
      this.node.css({
        'position': 'absolute',
        'overflow': 'hidden',
        'top': this.options.top,
        'left': this.options.left,
        'width': this.options.width,
        'height': this.options.height
      });

Wow! Wow! and WOW!!!

This has been a wonderful experience using and watching this project grow and grow to such a top level.

I noticed the site was offline a few months aback and I just came back to get some info and was pleasantly surprised to see the new site and logo. GREAT STUFF!! :)

Just 2 things I noted:

  1. Two minor typos:

Home: It work with >> It works with... (missing the 's' in works)

and

Donate: here's and ugly button >> here's an ugly button (should be 'an', not 'and')

  1. On the #Doc page, can you include the text 'Scroll down on the Github page for usage instructions' or something like that.

Again, great work!

Regards,
Trinione

Feature Request

First of all Great Plugin Love arrow navigation !!!

I thought it will be great to include working demo it could kick the learning curve up in the air.

Cheerz,
Guby

Page not scrolling correctly...sometimes

I'm having issues with some of the pages scrolling on my website. I'm not sure if it's your code or our CSS (we suspect it's something with our code conflicting yours), but on occasion scrollable pages don't scroll and instead they just go to the next page. It doesn't happen every time and so we're rather confused by it. The website is http://www.tttkjk.com/dosxx/

Add mousescroll

I'm not up to date on the latest changes but I think mouse scrolling should be integrated into Ascensor. At the moment I use a plugin to call the Ascensor next()/previous() method depending on the direction one is scrolling in.

It is the natural way in which people expect to interact with the website. A lot of users get confused with the layout especially if it's a simple vertical layout.

The javascript file contains the non-break spaces

When I use the plugin, I found that the file contains non-break space. the space made me crazy:>

Just like line 268, in the jquery.ascensor.js:

refresh: function()  {

The space after 'function()' is a non-break space. There are about 10 non-break spaces, and the ten spaces may make some coders unable to use the plugin directly. So hope to be fixed~

options doesn't work

The time doesn't work the easing too ?

  var ascensor = $('#ascensorBuilding').ascensor({                                                    
    easing: 'easeInElastic',                                                                           
    time: '5500',                                                                                      

    direction: [[0,0],[0,1],[1,1],[1,0]]                                                               
  });                                                                                                  
  var ascensorInstance = $('#ascensorBuilding').data('ascensor');                                      

  $(".links-to-floor li").click(function(event, index) {                                               
    ascensorInstance.scrollToFloor($(this).index());                                                   
  });                                                                                                  

  $(".links-to-floor li:eq("+ ascensor.data("current-floor") +")").addClass("selected");               

  ascensor.on("scrollStart", function(event, floor){                                                   
    $(".links-to-floor li").removeClass("selected");                                                   
    $(".links-to-floor li:eq("+floor.to+")").addClass("selected");                                     
   });                                                                                                  

$(".direction").click(function() {
ascensorInstance.scrollToDirection($(this).data("direction"));
});

Jump back to first?

Hi Léo,

I would like to create a similar website like Reverse Büro, where it is possible to navigate between the items (left / right) and sections (up / down) regardless which item is active, and if you switch between sections it jumps back to the first item.
I do not get it done with the new script. What is the solution?

Thanks in advance,

Koen.

Scrollbar issue using twitter-bootstrap

I'm using twitter-bootstrap framework.
The problem is the bottom of the scrollbar is hidden, and you can't access to the bottom of each section. To prove it I put a <h4> which indicates the end of the section, but you won't be able to see. May be I'm missing something.

Here is the fiddle: http://jsfiddle.net/zb8zB/8/ and here you can see the result in full screen mode: http://jsfiddle.net/zb8zB/8/embedded/result/.

Do you have any idea or fix to solve it? is a bug?

Add smart keyPress filter

replace this:

if ($("input, textarea, button").is(":focus")) return !1;

with something equivalent to this:

if ($("input, textarea, button").is(":focus")) {  
            if(key == 40 || key == 83 || key == 38 || key ==87 || key == 37 || key == 65 || key == 39 || key == 68 )
            {
                return false;
            }
        }

In order to let the form behavior intact.

activeFloor vs. activePage (or activeIndex)

I think there is some confusion about what a "floor" is. Ascensor treats all elements on the same x axis as being on the same floor.

e.g. if we have 4 pages as follows (pure horizontal navigation):
[1,0]
[1,1]
[1,2] <--- e.g. this is the current page, current index
[1,3]

ascensor reports that all of these pages would be activeFloor = 1, or "current-floor" =1.

This is good for some situations, but i would like to see a property that returns the "page" or activeIndex that we're currently on. In the example above, we are on the 3rd page, ascensor should return 3 (or 2 if it's zero-based) for this new activeIndex property.

Why?
The floor.from and floor.to properties in StartScroll and ScrollEnd report that all these pages are on the same floor as well, so you can never trap page change events that happen on the same "floor".

Unless i'm missing something, I suggest we need a new property activeIndex.

thanks.

Remove the scroll bars [Works now!]

The scrollbars are pretty disturbing. And no one need them because the
jquery does the scrolling job. Please remove the scrollbars.

The bug has fixed fixed :P.

scrollEnd

For some reason, when I call ascensor.on("scrollEnd", function(event, floor){ floor.from and floor.to are both the same value

Skips to wrong floor

I just wanted to see what the plugin looks like and went on http://www.waterevive.com. When I use my arrow keys to first go down and then to the right, the correct panel comes into place, but once the animation finishes, it jumps back to the first floor. The navigation is still on the "correct" panel and if I navigate from there, it jumps to the correct next floor.

I'm using the current Chrome Beta on Ubuntu.

ascensor.js is preventing default css/jquery events / behavior

(brilliant work on ascensor.js)

Ascensor is preventing default css/jquery mouseover/hover and click behavior on anchor links that are located inside page/floor divs.

For example, when i add google to a floor div, nothing happens when i cursor over the link. The cursor does not change to a hand, and also clicking on the link does not work either.

I have tried setting the CSS, etc. but no luck. It's like Ascensor is blocking the default CSS and event behavior.

// CLOSED
it turned out to be a z-index issue in the css.

dynamically appending elements

Hi,

Just a general question is there a way to notify the ascensor script that dom has been updated. Im appending content to the dom dynamically and ascensor desn't seem to be picking up the new element even though I add the position to ascensorMap. Please help if possible. Thanks

add alpineconstruction.ca to referrals

alpineconstruction.ca was developed using Ascensor.js

Note: it would be great to see parallax support added, or an example of how to integrate one of the popular parallax libs like skrollr.js or jparallax, or some other decent lib.

trigger "scrollToStage" without time as argument

From the API, we can trigger the method "scrollToStage", but as it don't take time as 3rd argument, the method should use the default time property, given when the plugin is instanciated.

After line 88, you should add a line like (not tested) :

time = time || self.options.time;

Ascensor pages can't be printed

Seems that using Ascensor makes the page unprintable. Safari shows a blank print preview and Chrome give the message "Print preview failed". I don't have a Windows machine to test IE.

I'm thinking this is something to do with the positioning?

Keep browser history clean

As an enhancement, it would be nice to prevent the browser history from being polluted with every content section view.

Hide navigation on certain floors?

Hi Léo,

I'm in the process of building my portfolio website using your amazing plugin. There's one thing I'm struggling with: I would like to be able to hide the navigation on certain floors.
Here you can see the work in progress: http://manifoldstudio.com/2014/
Basically, one the top floor, I'd like to only have the logo (linking to the second floor). But I can't figure out how to hide the navigation.
On the second floor, I'd like all the navigation to be visible.
And on the third and fourth floors, I'd like to only have the menu but not the left / right arrows.

Is there, by any chance, a way to achieve that? I feel like it might be something that other people might find interesting for their own project.
Any hints into the right direction would be greatly appreciated.

Cheers,

Thomas

Really amazing Plugin!! and How to produce the "active" text-link effect?

Hello Kirkas!! :)
Really amazing Plugin (what else can a web designer ask for??) 1. We can manage our different webpages as a full screen layout 2. We have an intuitive and easy to use navigation system and 3. the scrolling effect is fun and renders the content in an understandable way for the end user.

One thing I would like to know is regarding to the "active" link effect: when you go to some "floor" or div, you expect the corresponding text-link turns to an "active" state (changing the text color, for example).

When I use the ".links-to-floor" class method in the menu system, the corresponding script work perfectly:

ascensor.on("scrollStart", function(event, floor){
$(".links-to-floor a").removeClass("selected");

$(".links-to-floor a:eq("+floor.to+")").addClass("selected");
});

But when I try to point the link to an specific class (.example) using:

$(".exmple").click(function() {
ascensor.trigger("scrollToStage", 10);
});

I have not a clue about how to produce the "active" text-link effect at the corresponding "floor" or div.

I will apreciate to much if you give me some advice on this…
Thank you very much!
And congratulation for this awsome and usefull plugin!!

IE problem

Its not working properly on IE when u have animation from example [1,1] to [2,2] it does not going smooth, but jelly, unstable with vibrations on it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.