Skip to content

Commit

Permalink
redshift input: move float case into js
Browse files Browse the repository at this point in the history
* avoids a float cast on every slider move
  • Loading branch information
kecnry committed Jan 10, 2022
1 parent 1b5f887 commit 76c513e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions jdaviz/configs/default/plugins/line_lists/line_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ def _on_slider_updated(self, event):
return

# NOTE: _on_rs_redshift_updated will handle updating rs_rv
# NOTE: rs_redshift could be a string if entered by the user, so we cast old value to float
self.rs_redshift = float(self.rs_redshift) + event['new'] - event['old']
# NOTE: the input has a custom @input method in line_lists.vue to cast
# to float so that we can assume its a float here to minimize lag
# when interacting with the slider.
self.rs_redshift = self.rs_redshift + event['new'] - event['old']

@observe('rs_redshift')
def _on_rs_redshift_updated(self, event):
Expand Down
6 changes: 5 additions & 1 deletion jdaviz/configs/default/plugins/line_lists/line_lists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<v-row class="row-no-outside-padding row-min-bottom-padding">
<v-col>
<v-text-field
v-model="rs_redshift"
:value='rs_redshift'
@input='setRedshiftFloat'
step="0.1"
class="mt-0 pt-0"
type="number"
Expand Down Expand Up @@ -254,6 +255,9 @@
this.throttledSlider = _.throttle(
(v) => { this.rs_slider = v; },
this.rs_slider_throttle);
this.setRedshiftFloat = (v) => {
this.rs_redshift = parseFloat(v)
}
},
}
</script>
Expand Down

0 comments on commit 76c513e

Please # to comment.