Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "webpack --config webpack.prod.js",
"build_lib": "babel src --out-dir lib --ignore demo*,setupTests.js,*.test.js --copy-files --source-maps inline",
"build_demo": "webpack --config webpack.dev.js",
"build_demo": "webpack --config webpack.demo.prod.js",
"start": "webpack-dev-server --open --config webpack.dev.js",
"docs": "esdoc",
"pretty": "prettier --write --tab-width 4 \"src/**/*.js\"",
Expand Down
15 changes: 13 additions & 2 deletions src/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export default class Timeline extends React.Component {
this.updateDimensions = this.updateDimensions.bind(this);
this.grid_ref_callback = this.grid_ref_callback.bind(this);
this.select_ref_callback = this.select_ref_callback.bind(this);
this.throttledMouseMoveFunc = _.throttle(this.throttledMouseMoveFunc.bind(this), 20);
this.mouseMoveFunc = this.mouseMoveFunc.bind(this);
this.getCursor = this.getCursor.bind(this);

Expand All @@ -135,6 +136,7 @@ export default class Timeline extends React.Component {
componentDidMount() {
window.addEventListener('resize', this.updateDimensions);
}

componentWillReceiveProps(nextProps) {
this.setTimeMap(nextProps.items, nextProps.startDate, nextProps.endDate);
// @TODO
Expand Down Expand Up @@ -290,7 +292,11 @@ export default class Timeline extends React.Component {
if (canDrag) {
this._itemInteractable
.draggable({
enabled: true
enabled: true,
restrict: {
restriction: `.${topDivClassId}`,
elementRect: {left: 0, right: 1, top: 0, bottom: 1}
}
})
.on('dragstart', e => {
let selections = [];
Expand Down Expand Up @@ -729,7 +735,7 @@ export default class Timeline extends React.Component {
* Event handler for onMouseMove.
* Only calls back if a new snap time is reached
*/
mouseMoveFunc(e) {
throttledMouseMoveFunc(e) {
const {componentId} = this.props;
const leftOffset = document.querySelector(`.rct9k-id-${componentId} .parent-div`).getBoundingClientRect().left;
const cursorSnappedTime = getTimeAtPixel(
Expand All @@ -753,6 +759,11 @@ export default class Timeline extends React.Component {
}
}

mouseMoveFunc(e) {
e.persist();
this.throttledMouseMoveFunc(e);
}

render() {
const {onInteraction, groupOffset, timebarFormat, componentId, groupTitleRenderer} = this.props;

Expand Down
26 changes: 26 additions & 0 deletions webpack.demo.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = merge(common, {
entry: './src/demo_index.js',
mode: 'production',
devtool: 'source-map',
plugins: [
new HtmlWebpackPlugin({
title: 'React Timeline 9000',
template: 'src/demo.html',
chunksSortMode: 'dependency',
inject: 'body',
minify: {
removeComments: false,
collapseWhitespace: false
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
});
Loading