From b85becf903671084b0375d2b3868915ef7087b87 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Sat, 2 Apr 2016 08:57:50 -0700 Subject: [PATCH 1/3] Fixed VirtualScroll demo on iOS and touch devices. --- examples/src/components/Cities.js | 1 + examples/src/example.less | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/examples/src/components/Cities.js b/examples/src/components/Cities.js index a37012974f..46b6579375 100644 --- a/examples/src/components/Cities.js +++ b/examples/src/components/Cities.js @@ -59,6 +59,7 @@ var CitiesField = React.createClass({ {({ width }) => ( ( diff --git a/examples/src/example.less b/examples/src/example.less index 27dcc00006..801c1fc5d1 100644 --- a/examples/src/example.less +++ b/examples/src/example.less @@ -250,3 +250,7 @@ h6, .h6 { margin: 15px 0; color: #666; } + +.virtual-scroll { + z-index: 1; +} From 95367e78b36c331b7655d048a8143fc73d187cbf Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Sat, 2 Apr 2016 16:31:54 -0700 Subject: [PATCH 2/3] Cleaned up Cities example and added react-virtualized-select HOC --- examples/src/app.js | 2 +- examples/src/components/Cities.js | 95 +++++-------------------------- examples/src/index.html | 3 +- package.json | 3 +- 4 files changed, 19 insertions(+), 84 deletions(-) diff --git a/examples/src/app.js b/examples/src/app.js index a7b87ad788..18aeccb377 100644 --- a/examples/src/app.js +++ b/examples/src/app.js @@ -14,7 +14,7 @@ import States from './components/States'; ReactDOM.render(
- + diff --git a/examples/src/components/Cities.js b/examples/src/components/Cities.js index 46b6579375..1462e63e96 100644 --- a/examples/src/components/Cities.js +++ b/examples/src/components/Cities.js @@ -1,111 +1,44 @@ import React from 'react'; -import Select from 'react-select'; -import { AutoSizer, VirtualScroll } from 'react-virtualized'; +import VirtualizedSelect from 'react-virtualized-select'; const DATA = require('../data/cities'); -const OPTION_HEIGHT = 35; -const MAX_OPTIONS_HEIGHT = 200; - var CitiesField = React.createClass({ displayName: 'CitiesField', - propTypes: { - label: React.PropTypes.string, - searchable: React.PropTypes.bool, - }, - getDefaultProps () { - return { - label: 'Cities:', - searchable: true, - }; - }, - getInitialState () { - return { - country: 'AU', - disabled: false, - searchable: this.props.searchable, - selectValue: 'new-south-wales', - clearable: true, - }; - }, - switchCountry (e) { - var newCountry = e.target.value; - console.log('Country changed to ' + newCountry); + updateValue (newValue) { this.setState({ - country: newCountry, - selectValue: null + selectValue: newValue }); }, + getInitialState () { + return {}; + }, updateValue (newValue) { console.log('State changed to ' + newValue); this.setState({ selectValue: newValue }); }, - focusStateSelect () { - this.refs.stateSelect.focus(); - }, - toggleCheckbox (e) { - let newState = {}; - newState[e.target.name] = e.target.checked; - this.setState(newState); - }, - renderMenu({ focusedOption, focusOption, labelKey, options, selectValue, valueArray }) { - const focusedOptionIndex = options.indexOf(focusedOption); - const height = Math.min(MAX_OPTIONS_HEIGHT, options.length * OPTION_HEIGHT); - - return ( - - {({ width }) => ( - ( -
focusOption(options[index])} - onClick={() => selectValue(options[index])} - style={{ - backgroundColor: options[index] === focusedOption ? '#eee' : '#fff', - height: OPTION_HEIGHT, - display: 'flex', - alignItems: 'center', - padding: '0 .5rem' - }} - > - {options[index][labelKey]} -
- )} - rowsCount={options.length} - scrollToIndex={focusedOptionIndex} - width={width} - /> - )} -
- ); - }, render () { var options = DATA.CITIES; return (
-

World's Largest Cities

-

Uses react-virtualized to display data

-