mirror of
https://github.com/jcreek/SelectionWheel.git
synced 2026-07-14 03:33:43 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 77049455b9 | |||
| f549faab16 | |||
| fced394f3e | |||
| c51fca8425 | |||
| 866346ea01 | |||
| 050f87301c | |||
| 39d4ded1fb | |||
| eff426550b |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "SelectionWheel",
|
"name": "SelectionWheel",
|
||||||
"version": "1.2.0",
|
"version": "1.4.0",
|
||||||
"description": "A fun and simple selection wheel.",
|
"description": "A fun and simple selection wheel.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+36
-1
@@ -26,6 +26,8 @@ const color = d3.scaleOrdinal(d3.schemeCategory10);
|
|||||||
let data = [];
|
let data = [];
|
||||||
const testData = ['Person 1', 'Person 2', 'Person 3', 'Person 4'];
|
const testData = ['Person 1', 'Person 2', 'Person 3', 'Person 4'];
|
||||||
|
|
||||||
|
let imageUrlForSpinner = '';
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function rotTween(to) {
|
function rotTween(to) {
|
||||||
const i = d3.interpolate(oldrotation % 360, rotation);
|
const i = d3.interpolate(oldrotation % 360, rotation);
|
||||||
@@ -57,13 +59,31 @@ function makeArrowAndCircle(
|
|||||||
.attr('d', `M-${r * 0.15},0L0,${r * 0.05}L0,-${r * 0.05}Z`)
|
.attr('d', `M-${r * 0.15},0L0,${r * 0.05}L0,-${r * 0.05}Z`)
|
||||||
.style('fill', 'black');
|
.style('fill', 'black');
|
||||||
// draw spin circle
|
// draw spin circle
|
||||||
|
if (imageUrlForSpinner.length > 0) {
|
||||||
|
const defs = svg.append('svg:defs');
|
||||||
|
|
||||||
|
defs.append('svg:pattern')
|
||||||
|
.attr('id', 'image')
|
||||||
|
.attr('width', 1)
|
||||||
|
.attr('height', 1)
|
||||||
|
.attr('patternContentUnits', 'objectBoundingBox')
|
||||||
|
.append('svg:image')
|
||||||
|
.attr('xlink:href', imageUrlForSpinner)
|
||||||
|
.attr('width', 1)
|
||||||
|
.attr('height', 1)
|
||||||
|
.attr('x', 0)
|
||||||
|
.attr('y', 0)
|
||||||
|
.attr('preserveAspectRatio', 'xMaxYMax slice');
|
||||||
|
}
|
||||||
container
|
container
|
||||||
.append('circle')
|
.append('circle')
|
||||||
.attr('cx', 0)
|
.attr('cx', 0)
|
||||||
.attr('cy', 0)
|
.attr('cy', 0)
|
||||||
.attr('r', 60)
|
.attr('r', 60)
|
||||||
.style('fill', 'white')
|
.style('fill', 'white')
|
||||||
|
.style('fill', 'url(#image)')
|
||||||
.style('cursor', 'pointer');
|
.style('cursor', 'pointer');
|
||||||
|
if (imageUrlForSpinner.length === 0) {
|
||||||
// spin text
|
// spin text
|
||||||
container
|
container
|
||||||
.append('text')
|
.append('text')
|
||||||
@@ -73,6 +93,7 @@ function makeArrowAndCircle(
|
|||||||
.text('SPIN')
|
.text('SPIN')
|
||||||
.style('font-weight', 'bold')
|
.style('font-weight', 'bold')
|
||||||
.style('font-size', '30px');
|
.style('font-size', '30px');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawWheel() {
|
function drawWheel() {
|
||||||
@@ -182,7 +203,7 @@ function startOver() {
|
|||||||
function startSpinning() {
|
function startSpinning() {
|
||||||
const textArea = <HTMLInputElement>document.getElementById('input-lines');
|
const textArea = <HTMLInputElement>document.getElementById('input-lines');
|
||||||
const inputData = textArea.value.trim()
|
const inputData = textArea.value.trim()
|
||||||
? textArea.value.split('\n')
|
? textArea.value.split('\n').filter((elm) => elm)
|
||||||
: testData;
|
: testData;
|
||||||
const tempData = [];
|
const tempData = [];
|
||||||
for (let index = 0; index < inputData.length; index += 1) {
|
for (let index = 0; index < inputData.length; index += 1) {
|
||||||
@@ -228,6 +249,20 @@ function startSpinning() {
|
|||||||
const button = document.getElementById('startSpinning');
|
const button = document.getElementById('startSpinning');
|
||||||
button.onclick = startSpinning;
|
button.onclick = startSpinning;
|
||||||
|
|
||||||
|
const textArea = <HTMLInputElement>document.getElementById('input-lines');
|
||||||
|
if (window.localStorage.TextEditorData) {
|
||||||
|
textArea.value = window.localStorage.TextEditorData;
|
||||||
|
}
|
||||||
|
|
||||||
|
textArea.addEventListener('keyup', () => {
|
||||||
|
window.localStorage.TextEditorData = textArea.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
if (urlParams.has('imgUrl')) {
|
||||||
|
imageUrlForSpinner = urlParams.get('imgUrl');
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
loadServiceWorker();
|
loadServiceWorker();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ text{
|
|||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#image{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* Buttons */
|
/* Buttons */
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
|||||||
Reference in New Issue
Block a user