2017-06-08 05:25:47 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-05-05 05:10:49 +08:00
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
|
|
|
import CursorService from './service';
|
|
|
|
import Cursor from './component';
|
|
|
|
|
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
const CursorContainer = ({ cursorX, cursorY, ...rest }) => {
|
|
|
|
if (cursorX > 0 && cursorY > 0) {
|
2017-05-05 05:10:49 +08:00
|
|
|
return (
|
2017-07-29 08:29:40 +08:00
|
|
|
<Cursor
|
|
|
|
cursorX={cursorX}
|
|
|
|
cursorY={cursorY}
|
|
|
|
{...rest}
|
|
|
|
/>
|
2017-05-05 05:10:49 +08:00
|
|
|
);
|
|
|
|
}
|
2017-07-29 08:29:40 +08:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2017-05-05 05:10:49 +08:00
|
|
|
|
|
|
|
export default createContainer(() => {
|
2017-07-29 08:29:40 +08:00
|
|
|
const cursor = CursorService.getCurrentCursor();
|
|
|
|
|
|
|
|
let cursorX = -1;
|
|
|
|
let cursorY = -1;
|
2017-05-05 05:10:49 +08:00
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
if (cursor) {
|
2017-05-05 05:10:49 +08:00
|
|
|
cursorX = cursor.x;
|
|
|
|
cursorY = cursor.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2017-07-29 08:29:40 +08:00
|
|
|
cursorX,
|
|
|
|
cursorY,
|
2017-05-05 05:10:49 +08:00
|
|
|
};
|
|
|
|
}, CursorContainer);
|
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
|
|
|
|
CursorContainer.propTypes = {
|
|
|
|
// Defines the 'x' coordinate for the cursor, in percentages of the slide's width
|
|
|
|
cursorX: PropTypes.number.isRequired,
|
|
|
|
|
|
|
|
// Defines the 'y' coordinate for the cursor, in percentages of the slide's height
|
|
|
|
cursorY: PropTypes.number.isRequired,
|
|
|
|
};
|