Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fairblue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hosting
chat
fairblue
Commits
583ec9c4
Commit
583ec9c4
authored
8 years ago
by
Oleksandr Zhurbenko
Browse files
Options
Downloads
Patches
Plain Diff
Added animateTransform for the cursor for smoother animation
parent
416bda18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bigbluebutton-html5/imports/ui/components/presentation/cursor/component.jsx
+58
-22
58 additions, 22 deletions
...5/imports/ui/components/presentation/cursor/component.jsx
with
58 additions
and
22 deletions
bigbluebutton-html5/imports/ui/components/presentation/cursor/component.jsx
+
58
−
22
View file @
583ec9c4
import
React
,
{
Component
,
PropTypes
}
from
'
react
'
;
import
{
findDOMNode
}
from
'
react-dom
'
;
const
propTypes
=
{
//Width of the view box
...
...
@@ -43,35 +44,70 @@ const defaultProps = {
export
default
class
Cursor
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
cx
:
0
,
cy
:
0
,
finalRadius
:
5
,
fill
:
'
red
'
,
}
}
componentWillMount
()
{
let
calculatedData
=
this
.
calculatePositionAndRadius
(
this
.
props
);
this
.
setState
({
currentData
:
calculatedData
,
prevData
:
calculatedData
,
});
}
componentWillReceiveProps
(
nextProps
)
{
let
calculatedData
=
this
.
calculatePositionAndRadius
(
nextProps
);
this
.
setState
({
prevData
:
this
.
state
.
currentData
,
currentData
:
calculatedData
,
});
}
componentDidUpdate
()
{
const
{
cursor
}
=
this
.
refs
;
var
node
=
findDOMNode
(
cursor
);
node
.
beginElement
();
}
calculatePositionAndRadius
(
propsObj
)
{
return
{
//Adjust the x,y cursor position according to zoom
cx
:
(
propsObj
.
cursorX
*
propsObj
.
viewBoxWidth
)
+
propsObj
.
viewBoxX
,
cy
:
(
propsObj
.
cursorY
*
propsObj
.
viewBoxHeight
)
+
propsObj
.
viewBoxY
,
//Adjust the radius of the cursor according to zoom
finalRadius
:
propsObj
.
radius
*
propsObj
.
widthRatio
/
100
,
fill
:
propsObj
.
fill
,
}
}
render
()
{
const
{
viewBoxWidth
,
viewBoxHeight
,
viewBoxX
,
viewBoxY
,
widthRatio
,
cursorX
,
cursorY
,
fill
,
radius
,
}
=
this
.
props
;
//Adjust the x,y cursor position according to zoom
let
cx
=
(
cursorX
*
viewBoxWidth
)
+
viewBoxX
;
let
cy
=
(
cursorY
*
viewBoxHeight
)
+
viewBoxY
;
//Adjust the radius of the cursor according to zoom
let
finalRadius
=
radius
*
widthRatio
/
100
;
currentData
,
prevData
}
=
this
.
state
;
return
(
<
circle
cx
=
{
cx
}
cy
=
{
cy
}
r
=
{
finalRadius
}
fill
=
{
fill
}
/>
r
=
{
currentData
.
finalRadius
}
fill
=
{
currentData
.
fill
}
>
<
animateTransform
ref
=
"cursor"
attributeName
=
"transform"
type
=
"translate"
from
=
{
prevData
.
cx
+
"
"
+
prevData
.
cy
}
to
=
{
currentData
.
cx
+
"
"
+
currentData
.
cy
}
begin
=
{
'
indefinite
'
}
dur
=
"0.1s"
repeatCount
=
"0"
fill
=
"freeze"
/>
</
circle
>
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment