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

Allow number spinner lines to be configured #50

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Buttons accepts three attributes:
- **data-size**: xs/s/l/xl, defaults to medium
- **data-spinner-size**: 40, pixel dimensions of spinner, defaults to dynamic size based on the button height
- **data-spinner-color**: A hex code or any [named CSS color](http://css-tricks.com/snippets/css/named-colors-and-hex-equivalents/).
- **data-spinner-lines**: 12, the number of lines the for the spinner, defaults to 12

#### JavaScript

Expand Down
13 changes: 9 additions & 4 deletions js/ladda.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@
function createSpinner( button ) {

var height = button.offsetHeight,
spinnerColor;
spinnerColor,
spinnerLines;

if( height === 0 ) {
// We may have an element that is not visible so
Expand All @@ -385,14 +386,18 @@
spinnerColor = button.getAttribute( 'data-spinner-color' );
}

var lines = 12,
radius = height * 0.2,
// Allow buttons to specify the number of lines of the spinner
if( button.hasAttribute( 'data-spinner-lines' ) ) {
spinnerLines = parseInt( button.getAttribute( 'data-spinner-lines' ), 10 );
}

var radius = height * 0.2,
length = radius * 0.6,
width = radius < 7 ? 2 : 3;

return new Spinner( {
color: spinnerColor || '#fff',
lines: lines,
lines: spinnerLines || 12,
radius: radius,
length: length,
width: width,
Expand Down