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

add scrollTrigger option. Allow user to provide her own triggering eleme... #14

Merged
merged 2 commits into from
Feb 15, 2014

Conversation

freality
Copy link
Contributor

@freality freality commented Dec 4, 2013

This feature allows users to pass a custom triggering element to scrollUp.

It's a feature I needed for a project I'm working on.

Example Usage: (use a FontAwesome glyph as link icon)

$(function () {
  var scrollName = 'scrollUp'
    , scrollText = 'Scroll to top'
    , $icon = $('<i class="fa fa-arrow-up"/>')
    , $template = $('<a/>', {
        id: scrollName,
        href: '#top',
        title: scrollText,
      }).append($icon)
  ;

  $.scrollUp({
    scrollName: scrollName, // Element ID
    topDistance: '300', // Distance from top before showing element (px)
    topSpeed: 300, // Speed back to top (ms)
    animation: 'slide', // Fade, slide, none
    animationInSpeed: 200, // Animation in speed (ms)
    animationOutSpeed: 200, // Animation out speed (ms)
    scrollTrigger: $template, // Custom triggering element
    scrollImg: true,
    scrollText: scrollText, // Text for element
    activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
  });
});

@markgoodyear
Copy link
Owner

Hey @freality,

I'm not certain I understand what you're trying to achieve here. In the case you want to use an icon from FrontAwesome, rather than an image or text, this should work (untested) as scrollText allows HTML:

scrollText: '<i class="fa fa-arrow-up"/>'

Could you provide a demo of this (perhaps on JSFiddle) to clarify?

Cheers
Mark

@freality
Copy link
Contributor Author

freality commented Dec 5, 2013

Hi @markgoodyear,

I was hoping my simplified example would illustrate the need without getting too far into the weeds. You're right, you can pass html through the scrollText option. My use case is a bit more involved but not very apt to a fiddle.

I'm working on a library of UI elements for a CMS system. The CMS backend allows users to theme these elements on a per item basis. The system assigns classes and attributes and places the element in the DOM. When I init scrollUp, I must fetch the element from the DOM and pass it in as a option.

@markgoodyear
Copy link
Owner

Just coming back to revisit this, my heads been stuck in other projects.

Looking at it again, I can see it could be useful. Before I can merge, I'll run Grunt on to generate the dist/ files and bump the version. Will be merged in soon! :)

markgoodyear added a commit that referenced this pull request Feb 15, 2014
@markgoodyear markgoodyear merged commit 2df5d6a into markgoodyear:master Feb 15, 2014
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

Successfully merging this pull request may close these issues.

None yet

2 participants