You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.7 KiB
85 lines
1.7 KiB
7 years ago
|
<script>
|
||
|
import Align from '../index'
|
||
7 years ago
|
import BaseMixin from '../../_util/BaseMixin'
|
||
7 years ago
|
|
||
|
export default {
|
||
7 years ago
|
mixins: [BaseMixin],
|
||
7 years ago
|
data () {
|
||
|
return {
|
||
|
monitor: true,
|
||
|
align: {
|
||
|
points: ['tl', 'tc'],
|
||
|
},
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
getTarget () {
|
||
|
const ref = this.$refs.container
|
||
6 years ago
|
if (!ref) {
|
||
|
// parent ref not attached
|
||
|
return document.getElementById('container')
|
||
|
}
|
||
7 years ago
|
return ref
|
||
|
},
|
||
|
|
||
|
toggleMonitor () {
|
||
|
this.setState({
|
||
|
monitor: !this.$data.monitor,
|
||
|
})
|
||
|
},
|
||
|
|
||
|
forceAlign () {
|
||
6 years ago
|
this.$refs.align.forceAlign()
|
||
7 years ago
|
},
|
||
|
},
|
||
|
|
||
|
render () {
|
||
|
return (
|
||
|
<div
|
||
|
style={{
|
||
7 years ago
|
margin: '50px',
|
||
7 years ago
|
}}
|
||
|
>
|
||
|
<p>
|
||
6 years ago
|
<button onClick={this.forceAlign}>Force align</button>
|
||
7 years ago
|
|
||
6 years ago
|
<label>
|
||
|
<input type='checkbox' checked={this.monitor} onInput={this.toggleMonitor} />
|
||
|
|
||
|
Monitor window resize
|
||
|
</label>
|
||
7 years ago
|
</p>
|
||
|
<div
|
||
|
ref='container'
|
||
|
id='container'
|
||
|
style={{
|
||
|
width: '80%',
|
||
|
height: '500px',
|
||
|
border: '1px solid red',
|
||
|
}}
|
||
|
>
|
||
|
<Align
|
||
6 years ago
|
ref='align'
|
||
7 years ago
|
target={this.getTarget}
|
||
|
monitorWindowResize={this.$data.monitor}
|
||
|
align={this.$data.align}
|
||
|
>
|
||
|
<div
|
||
|
style={{
|
||
|
position: 'absolute',
|
||
|
width: '50px',
|
||
|
height: '50px',
|
||
|
background: 'yellow',
|
||
|
}}
|
||
|
>
|
||
|
source
|
||
|
</div>
|
||
|
</Align>
|
||
|
</div>
|
||
|
</div>
|
||
|
)
|
||
|
},
|
||
|
}
|
||
|
|
||
|
</script>
|