Code Monkey home page Code Monkey logo

beefup's Introduction

BeefUp

Build npm jsDelivr install size

Just a jQuery accordion plugin

https://schascha.github.io/BeefUp/

Examples:

Installation

You can use BeefUp in your project by installing it using npm:

npm install beefup --save

Usage

  1. Include jQuery

    <script src="dist/js/jquery.min.js"></script>
  2. Include plugin

    <script src="dist/js/jquery.beefup.min.js"></script>
  3. Add styles

    <link rel="stylesheet" href="dist/css/jquery.beefup.css">
  4. Add markup

    <article class="beefup">
        <h2 class="beefup__head">Headline</h2>
        <div class="beefup__body">My fancy collapsible content.</div>
    </article>
  5. Call the plugin

    <script>
        $(function() {
            $('.beefup').beefup();
        });
    </script>

Configuration

Option Type Default Description
accessibility boolean true Enable accessibility features like tab control
trigger string '.beefup__head' Selector of the trigger element
content string '.beefup__body' Selector of the collapsible content
openClass string 'is-open' Name of the class which shows if a accordion is triggered or not
animation string 'slide' Set animation type to "slide", "fade" or leave empty ""
openSpeed integer 200 Set the speed of the open animation
closeSpeed integer 200 Set the speed of the close animation
scroll boolean false Scroll to accordion on open
scrollSpeed integer 400 Set the speed of the scroll animation
scrollOffset integer 0 Additional offset to accordion position
openSingle boolean false Open just one accordion at once
stayOpen mixed null Leave items open, accepts null, integer (index) or string (selector, "first" or "last")
selfBlock boolean false Block close event on click
selfClose boolean false Close accordion on click outside
hash boolean true Open accordion with id on hash change
breakpoints array null Array of objects, see example
onInit function null Callback: Fires after the accordions initially setup
onOpen function null Callback: Fires after the accordions initially setup
onClose function null Callback: Fires after the accordions initially setup
onScroll function null Callback: Fires after the accordions initially setup

Advanced

API Methods

var $beefup = $('.beefup').beefup();

Open

$beefup.open($('#beefupID'));

Close

$beefup.close($('#beefupID'));

Click

$beefup.click($('#beefupID'));

Scroll

$beefup.scroll($('#beefupID'));

Callbacks

$('.beefup').beefup({
    onInit: function ($this) {
        // Do something after initially setup
    },
    onOpen: function ($this) {
        // Do something after accordion open the content
    },
    onClose: function ($this) {
        // Do something after accordion close the content
    },
    onScroll: function ($this) {
        // Do something after scroll animation
    }
});

HTML5 data attributes

<article class="beefup" data-beefup-options='{"animation": "", "openSpeed": 800}'>
    ...
</article>

Bugs? ๐Ÿ›

Please let me know: https://github.com/Schascha/BeefUp/issues

Buy me a Coffee โ˜•

Support this project and others via PayPal. Thanks

Changelog

Detailed changes for each release are documented in the release notes.

License

MIT

Copyright (c) 2014-present Sascha Kรผnstler

beefup's People

Contributors

dependabot[bot] avatar schascha 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

Watchers

 avatar  avatar  avatar  avatar

beefup's Issues

Stop toggle of open item

Hi there, is there a way to stop the toggling of an open item? stayOpen doesn't seem to work?

i.e. if this is open:

...and you click it, it remains open.

If you click another it closes this and opens the other.

Thanks in advance.
Al

BeefUp 1.2.0 animation is choppy + Question

Just wanted to let you know that the latest version has a very "choppy" animation when opening an accordion panel. I tried 1.1.7 instead and it works smoothly.

Also, I would like to have a "next" button inside each panel, when I click on it, it opens the next panel. Would you be able to help out because applying is-open dynamically doesn't do the trick haha

Great plugin BTW!

:)

Open through API and 'openSingle: true'

Nice plugin!

I have three accordion and three buttons. i want to open each accordion on respective button clicked. Also i set the openSingle option true. So when i am clicking buttons, previously opened accordion stays open so there are multiple accordion opens at a time. Is there any solution for that?

Also is there any option for expand all & collapse all?

Thanks.

stayOpen can't select the first item

Hi,

When I set stayOpen: 0, it doesn't select the first item and when I set stayOpen: 1 it selects the second item. How can I select the first item of the accordion?

Thanks,

Uncaught TypeError

Hi,

I tried out your plugin on my latest BigCommerce build. I'm continually getting a Type Error when browsing over the browser devtools.

Uncaught TypeError: $(...).beefup is not a function

Anyone else seen this?

Hash url

How can I implement beefup accodian using hash value from url

Accordion item should always stay open

Hi, I found your plugin and I liked it very much. Because it just worked out of the box. Now I have a feature request, that one item should always stay open. I.e. the first item. I think this is very usefull when you have a login/register form where the user can decide wether he has already an account or he should register. Or if you have a faq section and want to show how an answer should look like.

Start open

I don't think this behavior was mentioned before, sorry if it has.

When using openSingle, I would like to have one of the items start open.

Difference to stayOpen behaviour would be the selected item wouldnt stay open when clicked on other items.

Example (Except in BeefUp, you can close them all if you wanted.):
https://jqueryui.com/accordion/#default

Thanks for the awesome plugin, I will be grateful if you can consider this feature request.

What is the license of this plugin?

Hello, this plugin is wonderful and I like it very much, but I can not find any information about the license of this plugin. What is the license of this plugin?

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.