function move(h,point,mode)

%% Moves the selected waveform to the point "point" through a translation

% Modify the time and amplidude properties without affecting the timeseries
% so that the transaction object is able to capture the complete move once
if strcmp(mode,'motion')
    % Calculate the Y translation needed to move the startpt to the current
    % point. The start Y value is mean of the observation at 
    % h.SelectionStruct.StartPoint
    ydata = h.SelectionStruct.Selectedwave.Data.Amplitude;
    xdata = h.SelectionStruct.Selectedwave.Data.Time; 
    Ystartpt = tsnanmean(ydata(h.SelectionStruct.StartPoint,:));

    if isnan(Ystartpt(1))
        h.SelectionStruct.Selectedwave.Data.Amplitude = ...
              ydata+point(2)-tsnanmean(tsnanmean(ydata));
    else 
        h.SelectionStruct.Selectedwave.Data.Amplitude = ...
             ydata+point(2)-Ystartpt;
    end

    % Calculate the time translation needed to move the startpt to the current
    % point
    h.SelectionStruct.Selectedwave.Data.Time = ...
        h.SelectionStruct.Selectedwave.Data.Time + ...
        point(1)-xdata(h.SelectionStruct.StartPoint);

    %% Refresh - call draw on each wave to avoid triggering a viewchnage
    for k=1:length(h.waves)
       h.waves(k).RefreshMode = 'quick';
       h.waves(k).draw;
    end
    
    drawnow expose
elseif strcmp(mode,'complete') || strcmp(mode,'keyrelease')
    %% Get the transaction and recorder handles
    T = tsguis.transaction;
    recorder = tsguis.recorder;
    
    %% Find the deltaT
    if ~isempty(h.SelectionStruct.Selectedwave)
        thists = h.SelectionStruct.Selectedwave.DataSrc.Timeseries;
        deltaT = h.SelectionStruct.Selectedwave.Data.Time(1)*...
            tsunitconv(thists.TimeInfo.Units,h.TimeUnits)-thists.Time(1);

        %% If the recorder is on cache the M code in the transaction buffer   
        if strcmp(recorder.Recording,'on')     
            T.addbuffer('%% Timeseries translation')
            T.addbuffer(sprintf('%s.Data = %s.Data+%f;',thists.Name,thists.Name,...
                 tsnanmean(h.SelectionStruct.Selectedwave.Data.Amplitude(:)-thists.Data(:))),...
                 thists);
            T.addbuffer(sprintf('%s.Time = %s.Time+%f;', thists.Name,thists.Name,...
                 deltaT),thists);
        end

        %% Move events
        for k=1:length(thists.Events)
            thists.Events(k).Time = thists.Events(k).Time+deltaT;
        end

        %% During the drag all time series updates were routed to the @timedata
        %% Amplitlitude and Time, update the timeseries with these new values. 
        %% Do this in such a way that only one datachange event is fired
        set(thists.getContainer('Data'),...
            'Data',h.SelectionStruct.Selectedwave.Data.Amplitude);
        if ~isequal(h.SelectionStruct.Selectedwave.Data.Time,thists.Time)
            set(thists,'Time',h.SelectionStruct.Selectedwave.Data.Time)
        else
            thists.send('datachange')
        end

        %% Store transaction
        T.commit;
        recorder.pushundo(T);

        %% reset the refresh mode
        set(h.waves,'RefreshMode','normal')

        %% Reset the selection struct and the mouse pointer  
        set(h.AxesGrid,'YLimMode',h.SelectionStruct.YLimMode,'XLimMode',...
            h.SelectionStruct.XLimMode)
        if strcmp(mode,'complete')
            h.SelectionStruct.StartPoint = [];
            h.SelectionStruct.Centroid = [];
        end   
    end
end