Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add userDismissible option for toasts #6666

Open
wants to merge 1 commit into
base: v1-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions jade/page-contents/toasts_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ <h3 class="header">Options</h3>
<td>0.8</td>
<td>The percentage of the toast's width it takes for a drag to dismiss a Toast.</td>
</tr>
<tr>
<td>userDismissible</td>
<td>Boolean</td>
<td>true</td>
<td>If true, the user is allowed to dismiss the Toast by dragging it, otherwise it is only possible to dismiss the Toast programmatically as described below.</td>
</tr>
</tbody>
</table>
<br>
Expand Down
19 changes: 11 additions & 8 deletions js/toasts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
outDuration: 375,
classes: '',
completeCallback: null,
activationPercent: 0.8
activationPercent: 0.8,
userDismissible: true
};

class Toast {
Expand Down Expand Up @@ -97,13 +98,15 @@
if (e.target && $(e.target).closest('.toast').length) {
let $toast = $(e.target).closest('.toast');
let toast = $toast[0].M_Toast;
toast.panning = true;
Toast._draggedToast = toast;
toast.el.classList.add('panning');
toast.el.style.transition = '';
toast.startingXPos = Toast._xPos(e);
toast.time = Date.now();
toast.xPos = Toast._xPos(e);
if (toast.options.userDismissible) {
toast.panning = true;
Toast._draggedToast = toast;
toast.el.classList.add('panning');
toast.el.style.transition = '';
toast.startingXPos = Toast._xPos(e);
toast.time = Date.now();
toast.xPos = Toast._xPos(e);
}
}
}

Expand Down