-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jwanner83/develop
Develop
- Loading branch information
Showing
7 changed files
with
182 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ A dependency free script that let elements follow your cursor without a huge ove | |
## Usage | ||
1. Include the `follow.min.js` script to your project | ||
2. Add the `data-follow` attribute to the `position: absolute` elements which you want to follow the cursor | ||
3. Set the factor on how big they should follow like so `data-follow="100"` (higher equals more movement, if you | ||
3. Set the factor on how big they should follow like so `data-follow="100"` (higher equals less movement, if you | ||
leave it empty, it is set to 10. | ||
|
||
## Include Script | ||
|
@@ -13,7 +13,7 @@ leave it empty, it is set to 10. | |
2. `<script src"node_modules/follow-js/dist/follow.min.js"></script>` | ||
|
||
### unpkg | ||
1. `<script src="https://unpkg.com/[email protected].2/dist/follow.min.js"></script>` | ||
1. `<script src="https://unpkg.com/[email protected].3/dist/follow.min.js"></script>` | ||
|
||
## Options | ||
### Dynamically add new elements | ||
|
@@ -35,4 +35,4 @@ In the current state, the script wont work properly with a transition on the ele | |
Have a look in the `examples` folder to see some magic. | ||
|
||
## Contribute | ||
Feel free to open a Pullrequest or create a Issue on this project. | ||
Feel free to open a Pull request or create a Issue on this project. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Exact Example - follow.js</title> | ||
|
||
<style> | ||
body, html { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.item { | ||
position: absolute; | ||
height: 100px; | ||
width: 100px; | ||
background: black; | ||
} | ||
|
||
.grid { | ||
position: absolute; | ||
height: 100px; | ||
width: 100px; | ||
border: 1px solid red; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="item" data-follow></div> | ||
<section class="grid"></section> | ||
|
||
<script src="../dist/follow.min.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// adds a dot to the given position if enabled | ||
export function dot (x, y, color = 'red', timeout = 3000) { | ||
if (follow.debug.dot) { | ||
let dot = document.createElement('i') | ||
dot.style.position = 'absolute' | ||
dot.style.height = '1px' | ||
dot.style.width = '1px' | ||
dot.style.backgroundColor = color | ||
dot.style.zIndex = '100' | ||
dot.style.left = x + 'px' | ||
dot.style.top = y + 'px' | ||
document.body.append(dot) | ||
|
||
// because of performance issues remove the dot after the timeout | ||
setTimeout(() => { | ||
dot.remove() | ||
}, timeout) | ||
} | ||
} | ||
|
||
// log if enabled | ||
export function log (string, object = undefined) { | ||
if (follow.debug.log) { | ||
if (object) { | ||
console.log(string, object) | ||
} else { | ||
console.log(string) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ module.exports = { | |
filename: 'follow.min.js' | ||
}, | ||
mode: 'production', | ||
watch: true | ||
} |