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

Reset on shuffle option #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dist/jquery.slotmachine.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jQuery Slot Machine v4.0.0
* jQuery Slot Machine v4.0.1
* https://github.com/josex2r/jQuery-SlotMachineundefined
*
* Copyright 2014 Jose Luis Represa
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.slotmachine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery.slotmachine.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jquery.slotmachine.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions dist/slotmachine.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/slotmachine.min.js

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const eslint = require('gulp-eslint');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const clean = require('gulp-clean');
const runSequence = require('run-sequence');
const runSequence = require('gulp4-run-sequence');
const open = require('open');
const browserify = require('browserify');
const buffer = require('vinyl-buffer');
Expand All @@ -30,7 +30,9 @@ gulp.task('lint', () => {
return gulp.src([
'lib/**/*.js',
'tests/**/*.js'
])
], {
allowEmpty: true
})
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
Expand All @@ -40,7 +42,9 @@ gulp.task('lint', () => {
gulp.task('styles', () => {
return gulp.src([
'styles/index.css'
])
], {
allowEmpty: true
})
.pipe(autoprefixer({
browsers: ['last 10 versions', 'ie 8', 'ie 9'],
cascade: false
Expand Down Expand Up @@ -80,7 +84,7 @@ gulp.task('jquery-wrapper', () => {
.pipe(connect.reload())
.pipe(gulp.dest('dist'));
});
gulp.task('scripts', ['lint', 'jquery-wrapper'], () => {
gulp.task('scripts', gulp.series('lint', 'jquery-wrapper', () => {
return browserify({
entries: './lib/index.js',
extensions: ['.js'],
Expand All @@ -103,28 +107,31 @@ gulp.task('scripts', ['lint', 'jquery-wrapper'], () => {
.pipe(header(banner))
.pipe(connect.reload())
.pipe(gulp.dest('dist'));
});
}));

// Clean
gulp.task('clean', () => {
return gulp.src(['dist'], { read: false })
return gulp.src(['dist'], {
allowEmpty: true,
read: false
})
.pipe(clean());
});

// Build App
gulp.task('build', ['clean'], (callback) => {
gulp.task('build', gulp.series('clean', (callback) => {
runSequence(
'styles',
'scripts',
callback
);
});
}));

// Default task
gulp.task('default', ['build']);
gulp.task('default', gulp.series('build'));

// Watch
gulp.task('server', ['build'], () => {
gulp.task('server', gulp.series('build', () => {
// Watch .scss files
gulp.watch('styles/**/*.css', (event) => {
console.log(`File ${event.path} was ${event.type}, running tasks...`);
Expand All @@ -143,4 +150,4 @@ gulp.task('server', ['build'], () => {
});

open('http://localhost:8080');
});
})) ;
13 changes: 10 additions & 3 deletions lib/slot-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const defaults = {
onComplete: null, // Callback function(result)
inViewport: true, // Stops animations if the element isn´t visible on the screen
direction: 'up', // Animation direction ['up'||'down']
transition: 'ease-in-out'
transition: 'ease-in-out',
resetOnShuffle: true // Reset slot machine's display on shuffle
};
const FX_NO_TRANSITION = 'slotMachineNoTransition';
const FX_FAST = 'slotMachineBlurFast';
Expand Down Expand Up @@ -305,12 +306,18 @@ class SlotMachine {
const delay = this._getDelayFromSpins(spins);
// this.delay = delay;
this._changeTransition(delay);
this._changeTransform(this.bounds.to);

if (this.resetOnShuffle) {
this._changeTransform(this.bounds.to);
}

raf(() => {
if (!this.stopping && this.running) {
const left = spins - 1;

this._resetPosition(this.bounds.first);
if (this.resetOnShuffle) {
this._resetPosition(this.bounds.first);
}

if (left > 1) {
// Repeat animation
Expand Down
Loading