Skip to content

Commit

Permalink
fix attribute transition
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Jun 6, 2019
1 parent 3edc639 commit 63f9c7a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
9 changes: 5 additions & 4 deletions modules/core/src/lib/attribute.js
Expand Up @@ -210,7 +210,7 @@ export default class Attribute extends BaseAttribute {

const state = this.userData;

const {update, updateRanges} = state;
const {update, updateRanges, noAlloc} = state;

let updated = true;
if (update) {
Expand All @@ -229,9 +229,10 @@ export default class Attribute extends BaseAttribute {
const startOffset = Number.isFinite(startRow)
? this._getVertexOffset(startRow, this.bufferLayout)
: 0;
const endOffset =
Number.isFinite(endRow) || !Number.isFinite(numInstances)
? this._getVertexOffset(endRow, this.bufferLayout)
const endOffset = Number.isFinite(endRow)
? this._getVertexOffset(endRow, this.bufferLayout)
: noAlloc || !Number.isFinite(numInstances)
? this.value.length
: numInstances * this.size;

// Only update the changed part of the attribute
Expand Down
2 changes: 0 additions & 2 deletions modules/layers/src/path-layer/path-layer.js
Expand Up @@ -86,14 +86,12 @@ export default class PathLayer extends Layer {
},
instanceLeftPositions: {
size: 3,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getPath',
update: this.calculateLeftPositions,
noAlloc
},
instanceRightPositions: {
size: 3,
transition: ATTRIBUTE_TRANSITION,
accessor: 'getPath',
update: this.calculateRightPositions,
noAlloc
Expand Down
13 changes: 3 additions & 10 deletions test/apps/attribute-transition/app.js
Expand Up @@ -2,7 +2,6 @@
/* eslint-disable no-console */
import React, {Component} from 'react';
import {render} from 'react-dom';
import {StaticMap} from 'react-map-gl';
import DeckGL, {COORDINATE_SYSTEM, ScatterplotLayer, PolygonLayer, MapController} from 'deck.gl';

import DataGenerator from './data-generator';
Expand Down Expand Up @@ -47,12 +46,12 @@ class Root extends Component {
coordinateOrigin: MAP_CENTER,
data: points,
getPosition: d => d.position,
getColor: d => d.color,
getFillColor: d => d.color,
getRadius: d => d.radius,
transitions: {
getPosition: 600,
getRadius: 600,
getColor: 600
getFillColor: 600
}
}),
new PolygonLayer({
Expand Down Expand Up @@ -81,13 +80,7 @@ class Root extends Component {
viewState={viewState}
onViewStateChange={evt => this.setState({viewState: evt.viewState})}
layers={layers}
>
<StaticMap
{...viewState}
mapStyle="mapbox://styles/mapbox/light-v9"
mapboxApiAccessToken={MAPBOX_TOKEN}
/>
</DeckGL>
/>
<div id="control-panel">
<button onClick={this._randomize}>Randomize</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/apps/attribute-transition/index.html
Expand Up @@ -10,6 +10,6 @@
</style>
</head>
<body>
<script src='bundle.js'></script>
<script src='app.js'></script>
</body>
</html>
13 changes: 7 additions & 6 deletions test/apps/attribute-transition/package.json
Expand Up @@ -4,14 +4,15 @@
"start-local": "webpack-dev-server --env.local --progress --hot --port 3000 --open"
},
"dependencies": {
"deck.gl": ">=5.2.0-alpha.7",
"deck.gl": "^7.1.0",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-map-gl": "^3.2.0"
"react-dom": "^16.0.0"
},
"devDependencies": {
"buble-loader": "^0.4.0",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0"
"buble": "^0.19.3",
"buble-loader": "^0.5.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.1"
}
}
13 changes: 1 addition & 12 deletions test/apps/attribute-transition/webpack.config.js
Expand Up @@ -3,7 +3,6 @@

// avoid destructuring for older Node version support
const resolve = require('path').resolve;
const webpack = require('webpack');

const CONFIG = {
entry: {
Expand All @@ -25,17 +24,7 @@ const CONFIG = {
}
}
]
},

resolve: {
alias: {
// From mapbox-gl-js README. Required for non-browserify bundlers (e.g. webpack):
'mapbox-gl$': resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
}
},

// Optional: Enables reading mapbox token from environment variable
plugins: [new webpack.EnvironmentPlugin(['MapboxAccessToken'])]
}
};

// This line enables bundling against src in this repo rather than installed deck.gl module
Expand Down

0 comments on commit 63f9c7a

Please sign in to comment.