Skip to content

Commit

Permalink
Merge branch 'release/0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
James Warwood committed Nov 17, 2014
2 parents e6908f2 + 19bea28 commit 575be99
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
pkg: grunt.file.readJSON('_unified_manifest.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
Expand Down
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,42 @@ The descriptors can be combined by space-separating them, e.g.:
- `'top right'`
- etc.

#### Flip

Cursors can be flipped horizontally, vertically, or in both directions, by setting the `flip` option:

```javascript
// Horizontal flip
$('body').awesomeCursor('pencil', {
flip: 'horizontal'
});

// Vertical flip
$('body').awesomeCursor('pencil', {
flip: 'vertical'
});

// Horizontal and Vertical flip
$('body').awesomeCursor('pencil', {
flip: 'both'
});
```

```javascript
$('body').awesomeCursor('pencil', {
hotspot: [0, 17]
});
```

Or, using a string descriptor:

```javascript
$('body').awesomeCursor('pencil', {
hotspot: 'bottom left'
});
```


## Examples

```javascript
Expand All @@ -164,6 +200,14 @@ $('body').awesomeCursor('location-arrow', {
hotspot: 'top right',
size: 48
});

// Set the cursor to be a horizontally flipped version of the location arrow
$('body').awesomeCursor('location-arrow', {
color: '#0050FF',
hotspot: 'top right',
size: 48,
flip: 'horizontal'
});
```

## Browser Support
Expand All @@ -189,4 +233,5 @@ See [CONTRIBUTING.md](https://github.com/jwarby/jquery-awesome-cursor/blob/maste

## Release History

- `v0.0.2` - `17th Nov 2014` - Add the `flip` option to allow cursors to be flipped horizontally, vertically, or in both directions
- `v0.0.1` - `10th Nov 2014` - First version
2 changes: 1 addition & 1 deletion _unified_manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-awesome-cursor",
"version": "0.0.1",
"version": "0.0.2",
"description": "jQuery plugin for using FontAwesome icons as custom CSS cursors",
"keywords": [
"jquery-plugin",
Expand Down
2 changes: 1 addition & 1 deletion awesome-cursor.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-awesome-cursor",
"version": "0.0.1",
"version": "0.0.2",
"description": "jQuery plugin for using FontAwesome icons as custom CSS cursors",
"keywords": [
"jquery-plugin",
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-awesome-cursor",
"version": "0.0.1",
"version": "0.0.2",
"description": "jQuery plugin for using FontAwesome icons as custom CSS cursors",
"keywords": [
"jquery-plugin",
Expand Down
16 changes: 14 additions & 2 deletions dist/jquery.awesome-cursor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jquery-awesome-cursor - v0.0.0 - 2014-11-10
/*! jquery-awesome-cursor - v0.0.2 - 2014-11-17
* https://jwarby.github.io/jquery-awesome-cursor
* Copyright (c) 2014 James Warwood; Licensed MIT */
;(function(global, factory) {
Expand Down Expand Up @@ -118,6 +118,17 @@

context = canvas.getContext('2d');

// Check flip option
if (options.flip === 'horizontal' || options.flip === 'both') {
context.translate(canvas.width, 0);//canvas.height / 2);
context.scale(-1, 1);
}

if (options.flip === 'vertical' || options.flip === 'both') {
context.translate(0, canvas.height);
context.scale(1, -1);
}

context.fillStyle = options.color;
context.font = options.size + 'px FontAwesome';
context.textAlign = 'center';
Expand All @@ -143,6 +154,7 @@
$.fn.awesomeCursor.defaults = {
color: '#000000',
size: 18,
hotspot: [0, 0]
hotspot: [0, 0],
flip: ''
};
});
4 changes: 2 additions & 2 deletions dist/jquery.awesome-cursor.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-awesome-cursor",
"version": "0.0.1",
"version": "0.0.2",
"description": "jQuery plugin for using FontAwesome icons as custom CSS cursors",
"keywords": [
"jquery-plugin",
Expand Down
14 changes: 13 additions & 1 deletion src/jquery.awesome-cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@

context = canvas.getContext('2d');

// Check flip option
if (options.flip === 'horizontal' || options.flip === 'both') {
context.translate(canvas.width, 0);//canvas.height / 2);
context.scale(-1, 1);
}

if (options.flip === 'vertical' || options.flip === 'both') {
context.translate(0, canvas.height);
context.scale(1, -1);
}

context.fillStyle = options.color;
context.font = options.size + 'px FontAwesome';
context.textAlign = 'center';
Expand All @@ -140,6 +151,7 @@
$.fn.awesomeCursor.defaults = {
color: '#000000',
size: 18,
hotspot: [0, 0]
hotspot: [0, 0],
flip: ''
};
});
Binary file added test/expected/black-globe-flip-b-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/expected/lime-flag-flip-v-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/expected/red-pencil-flip-h-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions test/jquery-awesome-cursor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,52 @@
start();
});
}, true);

browserOnlyTest('can flip a cursor horizontally', function() {
expect(1);

$('body')
.awesomeCursor('pencil', {
color: 'red',
size: 18,
flip: 'horizontal'
})
.cursorMatchesImage(
'expected/red-pencil-flip-h-18.png', function(matches) {
ok(matches);
start();
});
}, true);

browserOnlyTest('can flip a cursor vertically', function() {
expect(1);

$('body')
.awesomeCursor('flag-checkered', {
color: '#00ff00',
size: 18,
flip: 'vertical'
})
.cursorMatchesImage(
'expected/lime-flag-flip-v-18.png', function(matches) {
ok(matches);
start();
});
}, true);

browserOnlyTest('can flip a cursor vertically and horizontally', function() {
expect(1);

$('body')
.awesomeCursor('globe', {
color: 'black',
size: 32,
flip: 'both'
})
.cursorMatchesImage(
'expected/black-globe-flip-b-32.png', function(matches) {
ok(matches);
start();
});
}, true);
}(this, jQuery));

0 comments on commit 575be99

Please sign in to comment.