Sha256: 734096dbc73ee161822add8b9bf12ae2c292a9bc2ad7a08c7240ff0d106fe213
Contents?: true
Size: 662 Bytes
Versions: 6
Compression:
Stored size: 662 Bytes
Contents
module Slippery module Processors module ImpressJs class AutoOffsets def initialize(offset_x = 1000, offset_y = 0) @offsets = [offset_x, offset_y] @position = [0,0] end def call(doc) doc.replace('.step') do |step| ['data-x', 'data-y'].each_with_index do |axis, idx| if step.has_attr?(axis) @position[idx] = step[axis].to_i else @position[idx] += @offsets[idx] end end step % { 'data-x' => @position[0], 'data-y' => @position[1] } end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems