Skip to content

Commit

Permalink
Close #7 - Two sticks in a row
Browse files Browse the repository at this point in the history
  • Loading branch information
bobboteck committed Apr 21, 2020
1 parent db716dd commit 4934a73
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# JoyStick

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a8b6ea1475c54ae9896e849e356dfe1d)](https://www.codacy.com/app/bobboteck/JoyStick?utm_source=github.com&utm_medium=referral&utm_content=bobboteck/JoyStick&utm_campaign=badger)
[![Join the chat at https://gitter.im/bobboteck/JoyStick](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bobboteck/JoyStick?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## About

Expand All @@ -14,7 +13,7 @@ Developed for Web Remote Control of Robot, the JoyStick can be used for all othe

> Note that code not use JQuery but only pure JavaScript.
**Actual release version is 1.1.4**. The complete history of project is avaliable in the [Releases page](https://github.com/bobboteck/JoyStick/releases).
**Actual release version is 1.1.5**. The complete history of project is avaliable in the [Releases page](https://github.com/bobboteck/JoyStick/releases).

Using appropriate methods that the object provides, you can know the position of the Stick is located.
The methods available are:
Expand Down Expand Up @@ -56,7 +55,7 @@ setInterval(function(){ x.value=joy.GetX(); }, 50);

You can see an example of result in this picture

![JoyStick in action!!!](http://bobboteck.github.io/joy/JoyStick.png "JoyStick in action!!!")
![JoyStick in action!!!](https://repository-images.githubusercontent.com/38121741/2ca19400-80a4-11ea-9034-0dee3dbec67f "JoyStick in action!!!")

But if you want see the JoyStick in action go to this [link](http://bobboteck.github.io/joy/joy.html).

Expand Down
24 changes: 24 additions & 0 deletions joy.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
<!DOCTYPE HTML>
<!--
The MIT License (MIT)
This file is part of the JoyStick Project (https://github.com/bobboteck/JoyStick).
Copyright (c) 2015 Roberto D'Amico (Bobboteck).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<html>
<head>
<title>Joy</title>
Expand Down
12 changes: 7 additions & 5 deletions joy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
*
* Modification History:
* Date Version Modified By Description
* 2020-04-03 Roberto D'Amico Correct: - internalRadius when change the size of canvas, thanks to @vanslipon for the suggestion
* 2020-04-20 1.1.5 Roberto D'Amico Correct: Two sticks in a row, thanks to @liamw9534 for the suggestion
* 2020-04-03 Roberto D'Amico Correct: InternalRadius when change the size of canvas, thanks to @vanslipon for the suggestion
* 2020-01-07 1.1.4 Roberto D'Amico Close #6 by implementing a new parameter to set the functionality of auto-return to 0 position
* 2019-11-18 1.1.3 Roberto D'Amico Close #5 correct indication of East direction
* 2019-11-12 1.1.2 Roberto D'Amico Removed Fix #4 incorrectly introduced and restored operation with touch devices
* 2019-11-12 1.1.1 Roberto D'Amico Fixed Issue #4 - Now JoyStick work in any position in the page, not only at 0,0
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Roberto D'Amico (Bobboteck)
* This file is part of the JoyStick Project (https://github.com/bobboteck/JoyStick).
* Copyright (c) 2015 Roberto D'Amico (Bobboteck).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -153,10 +155,10 @@ var JoyStick = (function(container, parameters) {
{
// Prevent the browser from doing its default thing (scroll, zoom)
event.preventDefault();
if(pressed==1)
if(pressed==1 && event.targetTouches[0].target == canvas)
{
movedX=event.touches[0].pageX;
movedY=event.touches[0].pageY;
movedX=event.targetTouches[0].pageX;
movedY=event.targetTouches[0].pageY;
// Manage offset
movedX-=canvas.offsetLeft;
movedY-=canvas.offsetTop;
Expand Down
5 changes: 3 additions & 2 deletions joy.min.js

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

0 comments on commit 4934a73

Please sign in to comment.